Error: Could not resolve 'storysolo' from state 'index'
Error: Could not resolve 'storysolo' from state 'index'
我的 index.php 页面有一个 ui-sref link 如下
<a ui-sref="storysolo({ storyId: headline.nid })">
我的主 js 文件加载 angular 代码如下
var rebelFleet = angular.module("CougsApp", ["ui.router","ngAnimate", "ui.bootstrap", "ngSanitize", "slick","CougsApp.headlines","CougsApp.story","CougsApp.recentstories" ]);
rebelFleet.config(function($stateProvider) {
// For any unmatched url, redirect to /state1
$stateProvider
.state('index', {
url: "",
views: {
"navViewPort": { templateUrl: '/components/nav/nav.html'
},
"contentViewPort": {
templateUrl: '/components/headlines/headlines.html',
controller: "headlinesCtrl"
},
"eventsViewPort": { templateUrl: '/components/scroller/scroller.html' },
"bottomContentViewPort": { templateUrl: '/components/recentstories/recentstories.html',
controller: "recentstoriesCtrl"
},
"rightsideViewPort": { templateUrl: '/components/social/social.html' },
"footerViewPort": { templateUrl: '/components/footer/footer.html' }
}
})
然后我让我的 story.js 文件尝试加载它自己的路由。如下
var ywing = angular.module('CougsApp.story', ["ui.router"]);
ywing.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state('storySolo', {
url: '/story/:storyId',
views: {
"navViewPort": { templateUrl: '/components/nav/nav.html'
},
"contentViewPort": {
templateUrl: '/components/story/story.html',
controller: "storyCtrl"
},
"footerViewPort": { templateUrl: '/components/footer/footer.html' }
}
})
});
因此,当我加载我的页面并单击 ui-sref link 时,我收到此错误
Could not resolve 'storysolo' from state 'index'
我的文件加载顺序如下
- angular.js,
- angular-sanitize.js,
- angular-ui-router.js,
- rebelFleet.js,(主js文件)
- story.js
我猜我在加载路由的方式上做错了,UI-Router 讨厌它。任何帮助将非常感激。
信不信由你,这很简单——就是区分大小写。状态名称必须适合 1) 定义以及 2) 调用方
// small solo
<a ui-sref="storysolo({ storyId: headline.nid })">
// capitalized Solo
$stateProvider.state('storySolo', {...
所以只使用其中之一,例如:
// not small solo
<a ui-sref="storySolo({ storyId: headline.nid })">
// the same name here
$stateProvider.state('storySolo', {...
我的 index.php 页面有一个 ui-sref link 如下
<a ui-sref="storysolo({ storyId: headline.nid })">
我的主 js 文件加载 angular 代码如下
var rebelFleet = angular.module("CougsApp", ["ui.router","ngAnimate", "ui.bootstrap", "ngSanitize", "slick","CougsApp.headlines","CougsApp.story","CougsApp.recentstories" ]);
rebelFleet.config(function($stateProvider) {
// For any unmatched url, redirect to /state1
$stateProvider
.state('index', {
url: "",
views: {
"navViewPort": { templateUrl: '/components/nav/nav.html'
},
"contentViewPort": {
templateUrl: '/components/headlines/headlines.html',
controller: "headlinesCtrl"
},
"eventsViewPort": { templateUrl: '/components/scroller/scroller.html' },
"bottomContentViewPort": { templateUrl: '/components/recentstories/recentstories.html',
controller: "recentstoriesCtrl"
},
"rightsideViewPort": { templateUrl: '/components/social/social.html' },
"footerViewPort": { templateUrl: '/components/footer/footer.html' }
}
})
然后我让我的 story.js 文件尝试加载它自己的路由。如下
var ywing = angular.module('CougsApp.story', ["ui.router"]);
ywing.config(function($stateProvider, $urlRouterProvider) {
$stateProvider.state('storySolo', {
url: '/story/:storyId',
views: {
"navViewPort": { templateUrl: '/components/nav/nav.html'
},
"contentViewPort": {
templateUrl: '/components/story/story.html',
controller: "storyCtrl"
},
"footerViewPort": { templateUrl: '/components/footer/footer.html' }
}
})
});
因此,当我加载我的页面并单击 ui-sref link 时,我收到此错误
Could not resolve 'storysolo' from state 'index'
我的文件加载顺序如下
- angular.js,
- angular-sanitize.js,
- angular-ui-router.js,
- rebelFleet.js,(主js文件)
- story.js
我猜我在加载路由的方式上做错了,UI-Router 讨厌它。任何帮助将非常感激。
信不信由你,这很简单——就是区分大小写。状态名称必须适合 1) 定义以及 2) 调用方
// small solo
<a ui-sref="storysolo({ storyId: headline.nid })">
// capitalized Solo
$stateProvider.state('storySolo', {...
所以只使用其中之一,例如:
// not small solo
<a ui-sref="storySolo({ storyId: headline.nid })">
// the same name here
$stateProvider.state('storySolo', {...