我的应用程序具有以下结构:
app/
js/
levels/
level-create
level-edit
level-list/
level-list.template.html
levellist.component.js
level-show/
level-show.template.html
levelshow.component.js
levels.module.js
我也有基本的资源服务,我注入每个组件和路由文件:
'use strict';
module.exports = angular
.module('app.levels.route', [])
.config(function($stateProvider) {
$stateProvider.state({
component: 'levellist',
name: 'levelIndex',
url: '/levels',
template: '<levellist></levellist>'
}).state({
component: 'levelshow',
name: 'levelShow',
url: 'levels/:id',
template: '<levelshow></levelshow>'
});
});
'use strict';
var angular = require('angular');
module.exports = angular
.module('app.levelsshow.component', ['ngMaterial'])
.component('levelshow', {
controller: LevelShowController,
templateUrl: '/app/js/levels/components/level-show/level-show.template.html'
});
LevelShowController.$inject = ['Level', '$scope', '$stateParams'];
function LevelShowController(Level, $scope, $stateParams) {
$scope.levelShow = Level.get({ id: $stateParams.id });
}
答案 0 :(得分:0)