【发布时间】:2017-10-26 14:28:47
【问题描述】:
我正在使用 angularjs 指令重定向另一个 html 页面。我在指令中编写 click 函数,但我在警告框中获取页面名称而不是重定向到另一个 html 页面。
示例.html:
<test1>
<button data-ng-click="click('/page.html')">Click</button>
</test1>
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',
});
}]);
我想重定向 page.html 如何做到这一点请建议我。 谢谢。
【问题讨论】:
标签: angularjs angularjs-directive