他のページでいくつかの問題が発生するため、私のapp.js以外にstateproviderを置くことができるかどうかを知りたいと思います。AngularJSのapp.js以外のStateProvider
app.js
var app = angular.module('myApp', 'ui.router']);
app.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
// route to show our basic form (/form)
.state('form', {
url: '/form',
templateUrl: 'templates/step_Form/form.html?v=' + new Date().getDay()
})
// url will be nested (/form/profile)
.state('form.upload', {
url: '/upload',
templateUrl: 'templates/step_Form/form-upload.html?v=' + new Date().getDay()
})
// url will be /form/interests
.state('form.content', {
url: '/content',
templateUrl: 'templates/step_Form/form-content.html?v=' + new Date().getDay()
})
$urlRouterProvider.otherwise('/form/upload');
})
私のコントローラ
angular.module('myApp').controller('ImportGeneralCtrl', function ($scope, $stateProvider, $urlRouterProvider) {
//myfunctions
}
私は状態プロバイダを使用して、私のHTMLにマルチステップフォームを統合しました。 どうすればapp.jsから状態プロバイダを取得し、コントローラにのみ適用できますか?
通常、コントローラーは状態を持っていて、状態はコントローラーを持つコンポーネントにマップします。 IIRCの場合、 '$ stateProvider'と' $ urlRouterProvider'はプロバイダであるためコントローラには挿入できません。 –