2016-05-28 11 views
2

Ich kann nicht herausfinden, warum mein Angular State Provider nicht funktioniert und es zeigt keine Fehler. Früher, als ich ngRoute benutzte, funktionierte alles, aber jetzt, als ich ui.router einschloss, scheint nichts zu funktionieren. Früher einmal i-Anwendung geöffnet,/#/link wurde (geroutet) erzeugt, aber jetzt ist es hängt nur auf myapp.com/

meine HTML index.html

<html> 
     <head> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <title>MyApp</title> 
     <style type="text/css"> 
      [ng\:cloak], [ng-cloak], .ng-cloak { 
      display: none !important; 
      } 
     </style> 
    </head> 
    <body class="hold-transition skin-blue sidebar-mini" ng-app="app"> 
     <div class="wrapper"> 
     <div class="content-wrapper"> 
       <div ng-view></div> 
     </div><!-- /.content-wrapper --> 
     </div> 
     <script src="plugins/angularJs/angular.js"></script> 
     <script src="plugins/angularJs/angular-ui-router.js"></script> 
     <script src="plugins/angularJs/angular-resource.js"></script> 
     <script src="plugins/angularJs/ui-bootstrap-tpls-1.3.2.js"></script> 
     <script src="app/app.js"></script> 
     <!-- Controllers --> 
     <script src="app/controllers/locations/locationsCtrl.js"></script> 
     <script src="app/controllers/dashboard/dashboardCtrl.js"></script> 
     <!-- Factories --> 
     <script src="app/factories/locationFactory.js"></script> 
     <script src="app/factories/countriesFactory.js"></script> 
     <script src="app/factories/provincesFactory.js"></script> 
     <!-- Filters --> 
     <script src="app/filters/selectionFilters.js"></script> 
    </body> 
</html> 

mein dashboard.html

<!-- Content Header (Page header) --> 
<section class="content-header"> 
    <h1>Dashboard</h1> 
    <ol class="breadcrumb"> 
     <li><a href="/"><i class="fa fa-dashboard"></i>Home</a></li> 
     <li class="active">Dashboard</li> 
    </ol> 
</section> 
<!-- Main content --> 
<section class="content"> 
    {{data}} 
</section> 

mein app.js

var app = angular.module('app', ['ui.router', 'ui.bootstrap']); 

app.config(function($stateProvider, $urlRouterProvider){ 
    $urlRouterProvider.otherwise("/dashboard"); 
    $stateProvider 
     .state('dashboard', { 
      url: "/dashboard", 
      templateUrl: "app/templates/dashboard/dashboard.html", 
      controller: 'dashboardCtrl' 
     }) 
     .state('locations', { 
      url: "/locations", 
      templateUrl: "app/templates/locations/locations.html", 
      controller: 'locationsCtrl' 
     }) 
     .state('/locations/add_location', { 
      url: "/locations/add_location", 
      templateUrl: "app/templates/locations/add_location.html", 
      controller: 'addLocationCtrl' 
    }); 

}); 

Schnittstelle und Konsolenausgabe Console Geladene Dateien enter image description here Ich hoffe, Sie wissen, was los ist oder was fehlt mir. Wenn Sie weitere Informationen benötigen, lassen Sie es mich wissen und ich werde zur Verfügung stellen.

+0

Können Sie Ihren HTML-Code anzeigen? (nicht die Skripte in der HTML) – AranS

+0

aktualisiert, ich hoffe, es ist genug, sonst sagen Sie mir –

+0

Können Sie direkt zu Ihrem/Dashboard oder/Standorte? –

Antwort

1

Ausprobieren

<base href="/"> 

in Ihrem HTML-Kopf und

$locationProvider.html5Mode(true); 

in Ihrer Route Config hinzuzufügen.

By the way, verwenden die Punktsyntax . nicht / in Zustand Erklärung:

.state('locations.add_location') 

Zu guter Letzt muss, <div ng-view></div> mit <div ui-view></div> lösen das Problem ersetzen.

+0

leid, es funktioniert nicht –

+1

vielleicht ersetzen '

' auf ''

+0

diese

es tat , aktualisiere deine Antwort! Danke! –

1

ersetzen <div ng-view></div> mit <div ui-view></div>

+0

Kopf ändern wird geschlossen, ich habe gerade Kopie nicht html korrekt auf stakoverflow –

Verwandte Themen