2016-04-08 21 views
-1

Angular'de hala yeni başlayan biriyim ve problemim açısal yönlendirmedir, hiçbir şekilde ng görüntüsünü açamıyorum. Test amacıyla tüm dosyalar aynı klasör içinde ve denetleyici admin.module.js temel açısal yönlendirme çalışmıyor

**Index.html**  
      <!DOCTYPE html> 
       <html ng-app="myApp"> 
       <link rel="stylesheet" src="/css/style.css"> 
        <script src="/libs/angular/angular.js"></script> 
        <script src="/libs/angular-route/angular-route.js"></script> 
        <script src="admin.module.js"></script> 
        </script> 
       <body> 
       <div ng-view></div> 
       </body> 

    **admin.module.js** 

      (function() { 
      "use strict"; 

      var app = angular.module("myApp", ["ngRoute"]); 

      app.config(function ($routeProvider) { 
       $routeProvider 
        .when('/test', { 
         templateUrl: 'test.html', 
         controller: 'AppCtrl' 
        }) 
        .otherwise({ 
         redirectTo: '/' 
        }); 
      }); 

      app.controller("AppCtrl", function ($scope) { 
       $scope.message = 'hello from the other side'; 
      }); 
     }()); 

    **test.html** 

     <h1>{{message}}</h1> 
    <p>Some text</p> 

plunker bir bağlantı

dahildir.

Konsol hatalarım yok ve tüm dosyalar yükleniyor.

Ben senin plunker 3 hatalar bulduk
+0

, ekran boş bir sayfa gösterir: sabit plunker görüyor musunuz? – ln206

+0

evet ve anladığımdan URL'ye test eklediğimde denetleyicideki mesajı görüntülemeliyim. –

cevap

0

: Sen açısal 1 sözdizimi ile 2 açısal kullandık

  1. Orada redirectTo oldu: '/' ama sadece/test güzergahları var

  2. hiçbir ng-app direktifi

Orada Lütfen oldu Eğer herhangi bir konsol hataları olmadığı için http://plnkr.co/edit/Nki3Djk4adihx31HABUi?p=preview

(function() { 
 
    "use strict"; 
 

 
    var app = angular.module("myApp", ["ngRoute"]); 
 

 
    app.config(function ($routeProvider) { 
 
     $routeProvider 
 
      .when('/test', { 
 
       templateUrl: 'test.html', 
 
       controller: 'AppCtrl' 
 
      }) 
 
      .otherwise({ 
 
       redirectTo: '/test' 
 
      }); 
 
    }); 
 

 
    app.controller("AppCtrl", function ($scope) { 
 
     $scope.message = 'hello from the other side'; 
 
    }); 
 
}());
<!DOCTYPE html> 
 
<html> 
 

 
    <head> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-route.js"></script> 
 
    <link rel="stylesheet" href="style.css" /> 
 
    <script src="script.js"></script> 
 
    </head> 
 

 
    <body ng-app="myApp"> 
 
    <ng-view></ng-view> 
 
    </body> 
 

 
</html>

İlgili konular