0
我試圖從一個模塊登錄到另一個使用$ state.go.I添加模塊在app.js also.still後我重新定向error.Help我找到一個解決方案。我已經通過了很多線程,但仍然得到相同的錯誤無法解析'商店'從狀態'mlogin'。Angularjs - 無法解析狀態'mlogin'中的'商店'
我controller.js
angular.module('login')
.controller('loginCtrl', loginCtrl)
.controller('passwordCtrl', passwordCtrl);
function loginCtrl ($scope,$http,$rootScope,$state, $stateParams,LoginFactory) {
$scope.merchant = {};
$scope.errMsg = null;
$rootScope.loggedIn = false;
$rootScope.successmsg = "";
$scope.loginSubmit = function(valid) {
$scope.submit = true;
if (valid) {
var data = { "email": $scope.merchant.email, "password": $scope.merchant.password };
LoginFactory.Login(data).success(function(res) {
if (res.status == 1) {
$rootScope.loggedIn = true;
$state.go('stores');
} else {
$rootScope.loggedIn = false;
$scope.errMsg = res.message;
}
}).error(function(error) {
});
}
};
$scope.removeAlert = function(){
$rootScope.successmsg = false;
};
};
我的配置文件,該文件是在另一個模塊 - storeConfig.js
angular
.module('stores',[])
.config(storesConfig);
function storesConfig($stateProvider, $compileProvider) {
$compileProvider.debugInfoEnabled(true);
$stateProvider.state('stores', {
url: '/stores?msg',
templateUrl: "app/stores/view.html",
controller: "storesCtrl",
data: {title: "Merchant Stores"},
resolve: {
checkLogin: checkLogin
},
// abstract: true,
}).
state('add_store', {
url: '/addstore',
templateUrl: "app/stores/add.html",
controller: "addstoreCtrl",
data: {title: "Add Store"},
resolve: {
checkLogin: checkLogin
}
}).
state('edit_store', {
url: '/editstore/:id',
templateUrl: "app/stores/edit.html",
controller: "editstoreCtrl",
data: {title: "Edit Store"},
resolve: {
checkLogin: checkLogin
}
}).
state('delete_merchant', {
url: '/deletemerchant/:id',
//templateUrl:"app/merchant/edit.html",
controller: "deletemerchantCtrl",
data: {title: "Delete Merchant"},
resolve: {
checkLogin: checkLogin
}
}).
state('myaccount', {
url: '/myaccount',
templateUrl: "app/merchant/edit.html",
controller: "editmerchantCtrl",
data: {title: "Edit Merchant"},
resolve: {
checkLogin: checkLogin
}
}).
state('subscription_merchant', {
url: '/subscription/:id',
templateUrl: "app/merchant/subscription.html",
controller: "subscriptionmerchantCtrl",
data: {title: "Merchant Details"},
resolve: {
checkLogin: checkLogin
}
});
}
感謝。
您能否提供一個所有代碼的工作示例?你在這裏沒有包含你的'app.js',沒有說明這些模塊如何一起工作。 – eminlala
這是我的app.js (函數(){ angular.module( 'zomongoMerchantApp',[ 'capitalizeFilter', 'ngMaterial', 'ui.select', 'ngSanitize', 「angularPayments 」, 'ngMap', 'ngRoute', 'ui.router', '註冊', '登錄', '存儲', ]);} )();在我的主要項目中,我已經分開了所有模塊,比如登錄模塊,註冊和存儲模塊。在每個模塊中,我有用於stateproviders,controller,views.html的分離配置文件,module.js.i給出了我的配置文件之一,控制器也this.this是模塊文件login.js angular.module('登錄',[]); – user8089866