Boy*_*tov 4 data-binding function angularjs ng-repeat angularjs-ng-click
我正在使用ng-click调用一个带有$ scope范围的参数的函数.不幸的是,不是从角度处理的参数或我得到此错误:
错误:[$ parse:syntax]语法错误:令牌':'不是从[:notification]开始的表达式[:notification]的第1列的主表达式.
导致错误的HTML代码段:
<div ng-click="goToNotif({{notification.id}})"></div>
Run Code Online (Sandbox Code Playgroud)
HTML代码段未从角度处理:
<div ng-click="goToNotif(notification.id)"></div>
Run Code Online (Sandbox Code Playgroud)
重要信息:notification从重复解析
<div(ng-repeat="notification in notifications")></div>
Run Code Online (Sandbox Code Playgroud)
小智 9
这是index.html的代码,单独定义"通知" -
<div ng-app="MyApp">
<div ng-controller="MainCtrl">
<div(ng-repeat="notification in notifications")>
<div ng-click="go(notification.id)"></div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在main.js中 -
var app = angular.module('MyApp', []);
app.controller('MainCtrl', function($scope) {
$scope.go = function() {
//write code here.
}
});
Run Code Online (Sandbox Code Playgroud)