javascript - AngularJS Expression in Expression -
is there way have angularjs evaluate expression within model data?
html:
<p> {{txt}} </p> model:
{ txt: "this text {{rest}}" } { rest: "and rest of it." } the end result be: this text , rest of it.
you can use $interpolate service interpolate string...
function ctrl ($scope, $interpolate) { $scope.txt = "this text {{rest}}"; $scope.rest = "and rest of it."; $scope.interpolate = function (value) { return $interpolate(value)($scope); }; } <div ng-app ng-controller="ctrl"> <input ng-model="txt" size="60" /> <p>{{ txt }}</p> <p>{{ interpolate(txt) }}</p> </div>
Comments
Post a Comment