加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 具有ng-click角度的函数的数据绑定参数

发布时间:2020-12-17 17:49:03 所属栏目:安全 来源:网络整理
导读:我正在使用ng-click调用一个带有$scope范围的参数的函数.不幸的是,不是从角度处理的参数或我得到此错误: Error: [$parse:syntax] Syntax Error: Token ‘:’ not a primary expression at column 1 of the expression [:notification] starting at [:notifi
我正在使用ng-click调用一个带有$scope范围的参数的函数.不幸的是,不是从角度处理的参数或我得到此错误:

Error: [$parse:syntax] Syntax Error: Token ‘:’ not a primary expression at column 1 of the expression [:notification] starting at [:notification].

导致错误的HTML代码段:

<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.
}
});

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读