I have a directive that I want to pass a value, but it does not work:
<p>{{testvar}}</p>
<my-fn info="{{testvar}}"></my-fn>
app.directive('myFn', function() {
return {
restrict: 'E',
templateUrl: 'templates/my-fn.html',
scope: {
info: "=info"
}
};
});
my-fn.html:
<p>the value is: {{info}}</p>
Result:
The value in <p>
tag is shown correctly, but the my-fn
directive is not shown and prints the following error in the console:
Error: [$parse:syntax] http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7Btestvar%7D
J/<@http://code.angularjs.org/1.4.3/angular.min.js:6:416
答案 0 :(得分:2)
To answer my own question: one has to neglect the curly brakets as follows:
<my-fn info="testvar"></my-fn>
If anyone knows why, please comment below.