0
我有,我想传递一个值的指令,但它不工作:如何将值传递给angularjs指令?
<p>{{testvar}}</p>
<my-fn info="{{testvar}}"></my-fn>
app.directive('myFn', function() {
return {
restrict: 'E',
templateUrl: 'templates/my-fn.html',
scope: {
info: "=info"
}
};
});
我-fn.html:
<p>the value is: {{info}}</p>
结果: 在<p>
标记值显示正确,但指令未显示,并在控制台中显示以下错误:
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
检查所有这些东西:https://www.reddit.com/r/angularjs/comments/2e1h35/can_somebody_explain_when_to_use_curly_brackets/ –