我正在使用angularjs指令重定向另一个html page.i我在指令中编写click函数,但我在警告框中获取页面名称而不是重定向到另一个html页面.
sample.html:
<test1>
<button data-ng-click="click('/page.html')">Click</button>
</test1>
Run Code Online (Sandbox Code Playgroud)
sample.js:
app.directive('test1',['$location', function(location) {
function compile(scope, element, attributes,$location) {
return{
post:function(scope, element, iAttrs,$location) {
scope.click=function(path)
{
alert("click"+path);
$location.path('/path');
};
}
};
}
return({
compile: compile,
restrict: 'AE',
});
}]);
Run Code Online (Sandbox Code Playgroud)
我想重定向page.html如何做到这一点请建议我.谢谢.