我正在使用ui.router來處理角度中的路由。這就是我要做的:如何在angularjs中使用ui-router獲取url參數
我有,我已經定義的狀態像這樣我的路由器文件:
state('login',{
url:'/login',
views:{
'slot1':{
templateUrl:'app/modules/authentication/authentication.html',
controller:'AuthenticationController',
controllerAs:'authCntrl'
}}})
我想要做的是登錄用戶在爲他們配備了一個網址在這種格式下
http://someapp.io/login?user=name&pass=423%%$dsad32
現在我該如何定義路由URL以及如何訪問用戶並在我的控制器中傳遞。不需要完整的代碼,只需要文檔的概念或鏈接即可。
這是我的控制器看起來像:
(function(){
angular.module("app.auth",[]).
controller("AuthenticationController", function($state, $stateParams, AuthenticationService, LoadingService){
var self = this;
console.log($stateParams);
}
而這個記錄以下勸慰:
Object {}
編輯:
奇怪的是,如果我改變的URL在我的路由器此:
url:'/instore_login?user=&pass='
我能夠獲得這些值。這是對的嗎?
在AuthenticationController
這實際上是一個沒有人會看的自動生成的URL。這僅供內部使用。此應用程序不在瀏覽器中運行,而是在CEF應用程序中運行。 –