Is there a way to evaluate an AngularJS expression in the template just once (ie. without data-binding)? -
it's best illustrate question example.
here template snippet:
<div class="title">{{action}} location</div>
double curly markup tells angularjs evaluate action
against current scope and create data-binding action
.
is there way tell angularjs evaluate action
once , done (ie. don't need data-binding/watch)?
i cannot find direct support of interporate once
feature in angular. can work around using separate variable gets copied action
once , never changes afterwards.
in controller:
$scope.action0 = action;
in template:
<div class="title">{{action0}} location</div>
edit : way define directive interpolates once , leave alone.
http://plnkr.co/edit/6ul1qgqhnh0bqk2af2jo?p=preview
js:
app.directive('staticbind', function(){ return function(scope, elem, attrs) { elem.text( scope[ attrs.staticbind ]); }; });
template:
<span static-bind="variable"></span>
Comments
Post a Comment