我正在使用ng-click调用一个带有$scope范围的参数的函数.不幸的是,不是从角度处理的参数或我得到此错误:
Error: [$parse:Syntax] Syntax Error: Token ‘:’ not a primary expression at column 1 of the expression [:notification] starting at [:notification].
<div ng-click="goToNotif({{notification.id}})"></div>
HTML代码段未从角度处理:
<div ng-click="goToNotif(notification.id)"></div>
重要信息:通过重复解析通知
<div(ng-repeat="notification in notifications")></div>
解决方法
这是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>
在main.js中 –
var app = angular.module('MyApp',[]); app.controller('MainCtrl',function($scope) { $scope.go = function() { //write code here. } });