Display a scope variable which is similar to ng-repeat element in Angularjs
These are my scope variables
$scope.published = true;
$scope.count = 3;
I also have an array called labels
$scope.labels = ['published', 'count'];
In the view I want to view these data as the label name - label value.
<div ng-repeat="label in labels">
{{label}} - {{Here I want the value from the Scope variable}}
</div>
Can someone help me how to access the scope variable in this kind of scenario?
ng-controller, which is assigned to the same controller containing your$scopevariables, it should just be a matter of using{{count}}or{{published}}in your HTML if you want to display the values literally. If you've aliased your controller (e.g.ng-controller="Ctrl as foo") then you'll need to prefix the interpolations with the alias (e.g.{{foo.count}}).labelscollection to objects which index the$scopeproperties, or have a function which returns the latter and make use of it with yourng-repeat(e.g.ng-repeat="obj in getObjs()"). If thelabelscollection ever varies, then the latter approach ensures you don't need to explicitly remap the labels.