2016-01-24 33 views
1

它的我...再次... 嗯,我需要在登錄sussesufull時在我的控制器上添加一個AngularJS的重定向。我讀過loooooot,我發現this。這個例子很明顯使用ui-router,非常簡單。 我把我的index.html的所有代碼「基地」我的應用程序,我把一個div:登錄後的AngularJS重定向

<body ng-app="solempApp"> 
    <!-- Start of first page --> 
    <div ui-view></div> 
</body> 

而且我的第一個頁面的其餘部分都在login.htm。這個想法是:login.html的所有內容出現在這個<div> ui-view></div>是正確的?

再有就是我在我的應用程序配置:

angular 
.module('solempApp',['ngMessages', 'angular-loading-bar','ui.router']) 
.config(function($stateProvider, $urlRouterProvider) { 
    $urlRouterProvider.otherwise('/solempmobile'); 
    $stateProvider 
    // HOME STATES AND NESTED VIEWS ======================================== 
    .state('solempmobile', { 
     url: '/solempmobile', 
     templateUrl: 'login.html' 
    }) 
    // ABOUT PAGE AND MULTIPLE NAMED VIEWS ================================= 
    .state('about', { 
     // we'll get to this in a bit  
    }); 
}) 

問題是,當我把網址在我的網頁瀏覽器:

http://192.168.0.203/solempmobile 

回報:

http://192.168.0.203/solempmobile/#/solempmobile 

而且全部都在空白頁面中。 Web服務器是IIS,並且該應用程序位於虛擬目錄中。主頁是http://192.168.0.203/solempmobile。 是我做錯了什麼?

[更新1]

,所以我有環視代碼,最後它的工作原理... buuuut .....沒有達到預期的方式。路線工作......但與jquery手機相關的ccs不。 我必須把關閉此:

<div data-role="page"> 

的局部視圖外,但頁面是如此醜陋...

回答

1

你可以簡單地重定向使用HTML!所以首先做一個簡單的HTML文件,把它的index.html ...

然後做一個狀態是在主頁「/」是這樣的:

.config(function($stateProvider, $urlRouterProvider) { 
    $urlRouterProvider.otherwise('/solempmobile'); 
    $stateProvider 
    // HOME STATES AND NESTED VIEWS ======================================== 
    .state('Home', { 
     url: '/' 
     templateUrl: 'index.html' 
     }) 

    .state('solempmobile', { 
     url: '/solempmobile', 
     templateUrl: 'login.html' 
    }) 
    // ABOUT PAGE AND MULTIPLE NAMED VIEWS ================================= 
    .state('about', { 
     // we'll get to this in a bit  
    }); 
}) 

然後在您的index.html:你可以有一個meta標籤自動重定向... IDK如果這是正確的網址,但你可以改變它:

<html> 
    <head> 
    <META http-equiv="refresh" content="5;URL=http://192.168.0.203/solempmobile/#solempmobile/solempmobile"> 

<!-- Type in whatever HTTPS you want to go to. In your case your login page... --> 
    </head> 


    </body> 
</html> 

希望這有助於!

+0

嗨,我的朋友!謝謝您的幫助。現在我把aaaall de項目放到一箇舊文件夾中,因爲我懷疑jqery mobile與angularJS不兼容。查看我的更新1 ... –

+0

這項工作@AliBriceño – amanuel2

+0

這項工作...但我發現AngularJS和jQuery Mobile尚未合作。 –