我使用$scope
做了访问导航,我基于点击使用了它们,并且我使用了它们。我无法在变量容纳中设置网址。正确的URL是http://www.example.com/base/index
或http://www.example.com/base/thread
或http://www.example.com/base/tag
。 但结果始终是`http://www.example.com/base/index甚至认为,我点击另一个导航。
当我搜索我的问题后,答案是使$routeProvider
和$location
。我可以在$ scope中使用$scope
并设置URL吗?
这是我的代码:
$scope.states = {};
$scope.states.activeItem = 'nav1';
$scope.items = [{
id: 'nav1',
target: 'home',
title: 'Home',
icon: 'fa fa-home fa-3x'
}, {
id: 'nav2',
target: 'thread',
title: 'Thread + Answer',
icon: 'fa fa-briefcase fa-3x'
}, {
id: 'nav3',
target: 'tag',
title: 'Tag',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav4',
target: 'trending_tag',
title: 'Trending Tag',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav5',
target: 'category',
title: 'Category',
icon: 'fa fa-briefcase fa-3x'
},
{
id: 'nav6',
target: 'user',
title: 'User',
icon: 'fa fa-user-circle-o fa-3x'
}];
$scope.callToAction = function(actionName){
if($scope[actionName]){
$scope[actionName]();
}else{
alert("YOUR PAGE NOT FOUND BECAUSE AKU BELUM BUAT PAGE NYA HEHE");
}
};
顺便说一句,$scope.items
执行我的导航。
至于它似乎你想创建一个代码来显示菜单或东西有效的网址,对不对? – SPViradiya
是的,你说得对。但我很困惑,如果使用这种方式设置网址。 – userpr