另一个问题球员:)如果我离开templateUrl在我的路由空,范围可查询,但没有模板的表现。 但是,如果我写它只是作为链接plunker项目,它使链接无法点击:(但只是为LI>一个元素...也plunker我不能让它可行的,不知道为什么...任何人? http://plnkr.co/edit/VKhhcSmepMTxBT7R5AuO
这里是ap.js本身帮助
(function(){
var portApp = angular.module('portApp', ['ui.router']);
portApp.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
$urlRouterProvider.otherwise('/home');
$stateProvider
.state('root', {
url: '/home',
abstract: true,
templateUrl: 'views/listView.html',
controller: 'ListController'
})
.state('home', {
url: '/home',
templateUrl: 'views/listView.html',
controller: 'ListController'
})
.state('about', {
url: '/about',
templateUrl: 'views/resumeView.html'
})
.state('items', {
url: '/items/:itemLink',
templateUrl: 'views/itemView.html',
controller: 'ItemController'
});
$locationProvider.html5Mode(true);
});
portApp.factory("workFactory", function() {
var works = [
{
Title: "Sprite",
subTitle: "",
Link: "sprite",
Thumbnail: "img/portfolio02.png",
Image: "img/ismont.png"
},
{
Title: "Pepsi",
subTitle: "Kristályvíz",
Link: "pepsi",
Thumbnail: "img/portfolio03.png",
Image: "img/sanofimont.png"
}
];
return {
list: function() {
return works;
},
selected: function(detPath) {
selected = works.filter(function(work) {
return work.Link == detPath;
});
return selected;
}
};
});
portApp.controller("ListController", ["$scope", "workFactory",
function($scope, workFactory) {
$scope.allWorks = workFactory.list();
}
]);
portApp.controller("ItemController", ["$scope", "workFactory", "$stateParams",
function($scope, workFactory, $stateParams) {
var detPath = $stateParams.itemLink;
//$scope.selectedWork = workFactory.selected(detPath);
$scope.selectedWork = workFactory.selected(detPath)[0];
alert($scope.selectedWork);
}
]);
})();