簡體   English   中英

角UI路由器不起作用

[英]Angular UI router not working

**此ui路由器的js文件正確與否。錯誤顯示為“錯誤:未知的提供者:routerApp的$ stateProvider”

該js文件已加載到HTML文件中。

**

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

routerApp.config(function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/template1');

$stateProvider

    // HOME STATES AND NESTED VIEWS ========================================
    .state('template1', {
        url: '/temp1',
        templateUrl: 'templates/template1.html'
    })

    // ABOUT PAGE AND MULTIPLE NAMED VIEWS =================================
    .state('template2', {
        // we'll get to this in a bit       
    });

});


<!-- MAIN CONTENT -->
<div class="container">

<!-- THIS IS WHERE WE WILL INJECT OUR CONTENT ============================== -->
<div ui-view></div>

</div>

</body>
</html>

請幫忙。謝謝

請在這里查看: http : //plnkr.co/edit/FYxpaHpKgvpEu6f1TZ7l?p=preview

var routerApp = angular.module("routerApp", ["ui.router"]);



routerApp.config(
  ["$stateProvider", "$urlRouterProvider",
    function($stateProvider, $urlRouterProvider) {

      $urlRouterProvider.otherwise("/template1");

      $stateProvider
        .state("template1", {
          url: "/template1",
          templateUrl: "template1.html",
          controller: "tmp1Controller"
        })
        .state("template2", {
          url: "/template2",
          templateUrl: "template2.html",
          controller: "tmp2Controller"
        })



      ;

    }
  ]);

routerApp.controller("mainCtrl", ["$scope",
  function($scope) {

  }
]);
routerApp.controller("tmp1Controller", ["$scope",
  function($scope) {

  }
]);

routerApp.controller("tmp2Controller", ["$scope",
  function($scope) {

  }
]);

我有同樣的問題,解決了替換問題

<div ui-view></div>

通過

<ui-view> 
 <i>Loading ....</i>
</ui-view>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM