当我绑定以下内容时,我需要触发ng-click
<a href='#' ng-click ='GotoUrl('www.cnn.com')'>CNN</a>
我得到$ santize:badparse
我做错了什么?
答案 0 :(得分:2)
您使用了嵌套引号。试试这个:
<a href='#' ng-click ='GotoUrl("www.cnn.com")'>CNN</a>
答案 1 :(得分:2)
看到这一点。
http://jsfiddle.net/jigardafda/08k1ztsa/1/
JS
var myApp = angular.module('myApp', []);
myApp
.controller('myCtrl', function($scope){
$scope.GotoUrl = function(url){
window.open(url);
};
});
HTML
<div ng-app="myApp">
<div ng-controller = "myCtrl">
<a href='#' ng-click ='GotoUrl("http://www.cnn.com")'>CNN</a>
</div>
</div>