javascript - data-ng-bind from $scope controller -
i'm lost, me?
i have value in $scope retrieved json file:
in controller:
$scope.scopetitle = title; in json file:
"title": "fruit.id || 'empty'" the fruit.id retrieved backend, , want display it's id in html.
everything works fine if in html sth like:
<span class="navbar-brand"  data-ng-bind="fruit.id || 'empty'" /> the result on html is:
fruit/12 or empty <- , it's if want pass via $scope, this:
<span class="navbar-brand"  data-ng-bind='scopetitle' /> it's not working, result on html is:
fruit.id || 'empty' <- it's not my html generated in template in directive , i'm using $compile function compile html code.
how write ng-bind expression achieve result via $scope?
try use $scope.$eval in controller , use declare scopetitle
$scope.scopetitle = $scope.$eval(title); **update : * can see assigning "fruit.id || 'empty'" string expression need use $eval
and why not using this
<span class="navbar-brand">{{scopetitle}}</span> 
Comments
Post a Comment