Angularjs Angular ui.router,任何结果和错误
我对我的观点有点问题。我尝试使用ui.router来配置我的路由,但它不起作用。我试着用控制台,但很清楚。我不知道我能做些什么来解决这个问题Angularjs Angular ui.router,任何结果和错误,angularjs,angular-ui-router,Angularjs,Angular Ui Router,我对我的观点有点问题。我尝试使用ui.router来配置我的路由,但它不起作用。我试着用控制台,但很清楚。我不知道我能做些什么来解决这个问题 (函数(){ "严格使用",; const-app=angular.module('myApp',['common.services','common.servicesMock','ui.router']); app.config(函数($stateProvider,$locationProvider){ $locationProvider.hashPre
(函数(){
"严格使用",;
const-app=angular.module('myApp',['common.services','common.servicesMock','ui.router']);
app.config(函数($stateProvider,$locationProvider){
$locationProvider.hashPrefix(“”);
$stateProvider
.state('newList'{
模板:“views/newsListView.html”,
url:“/news”,
控制器:“newsCtrl作为vm”,
});
//删除管线中的#
$locationProvider.html5Mode({
启用:对,
requireBase:错误
});
});
}())
维基
这是我要在浏览器中显示的视图
{vm.showCategories?“隐藏”:“Show”}Categories
{{cate}}
杰出的
{{newsItem.date | date}}
{{newsItem.newsTitle}
{{newsItem.NewsDescription.substring(0200)+“…”}
最后消息
{{newsItem.date | date}}
{{newsItem.newsTitle}
{{newsItem.NewsDescription.substring(0200)+“…”}
谢谢您的时间。尽管您声明了状态,但您需要在第一次启动时实际“输入”状态。假设
newList
状态是您想要进入的状态,您可以通过两种方式进行操作:
$urlRouterProvider
路由到根目录下的/news
:
app.config(function($stateProvider, $locationProvider, $urlRouterProvider) {
$locationProvider.hashPrefix("");
$urlRouterProvider.when('/','/news');
$stateProvider
.state('newList', {
template: 'views/newsListView.html',
url: '/news',
controller: 'newsCtrl as vm',
});
//Delete the # in the routes
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
。以角度运行方法
app.run(['$state',function($state){
$state.go('newList');
}])
虽然您声明了状态,但在第一次启动状态时,实际上需要“输入”状态。假设
newList
状态是您想要进入的状态,您可以通过两种方式进行操作:
$urlRouterProvider
路由到根目录下的/news
:
app.config(function($stateProvider, $locationProvider, $urlRouterProvider) {
$locationProvider.hashPrefix("");
$urlRouterProvider.when('/','/news');
$stateProvider
.state('newList', {
template: 'views/newsListView.html',
url: '/news',
controller: 'newsCtrl as vm',
});
//Delete the # in the routes
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
});
。以角度运行方法
app.run(['$state',function($state){
$state.go('newList');
}])