//模板
<div ng-controller="myController">
<input type="text" ng-model="name">
<p>{{name}}</p>
<p>{{10+10}}</p>
<button type="button" ng-click="{{myFunction()}}">click Me !!</button>
<p ng-show="{{myFunction()}}">The name is {{ name | uppercase }}</p>
</div>
// Controller
myApp.controller('myController', function ($scope) {
$scope.name = 'Ranka';
$scope.myFunction = function(){
return true;
};
});
Run Code Online (Sandbox Code Playgroud)
在ng-click的情况下失败了
angular.js:14525错误:[$ parse:syntax]语法错误:表达式[{{myFunction()}}的第2列的令牌'{'无效键,从[{myFunction()}}开始.