2014-01-05 4 views
0

나는 내 인생에서 내가 잘못하고있는 것을 파악할 수 없다. 몇 가지 기본 AngularJS 라우팅을 수행하는 John Linquist 비디오를 보러갑니다. partials 폴더에 내 index.html 페이지에 내 테이블이없고 (따라서 ng-view을 사용하지 않아서 라우팅을 구성 할 필요가 없으므로 작동합니다.) 그러나 테이블의 일부분을Angular JS와의 라우팅 문제

angular.module('enterprise',[]) 
    .config(function($routeProvider){ 
     $routeProvider.when("/",{templateUrl:"/partials/list.html"}) 
    }) 
//this is the that iterated over in the partial view's ng-repeat 
function AppController($scope){ 
    $scope.crew =[ 
     {name:'Picard',description:'captain'}, 
     {name: 'Riker',description:'number 1'}, 
     {name:'Word',description:'Security'} 
    ] 
} 

index.html을

<!DOCTYPE html> 
<html> 
<head> 
    <title>Angular JS Routing</title> 
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/> 
    <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet"> 
</head> 
<body> 
<div ng-app="enterprise" ng-controller="AppController"> 
    <a href="/"><h2>Enterprise Crew</h2></a> 
    <ng-view></ng-view> 
    //list.html should be injected here 
</div> 

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script> 
<script src="js/app.js"></script> 
</body> 
</html> 

list.html

을 app.js (각 문서에서) http://goo.gl/nZAgrj : <ng-view></ng-view> 다음 나는 오류
<table class="table table-striped" style="width: 250px"> 
    <thead> 
    <tr> 
     <td>Name</td> 
     <td>Description</td> 
     <td><i class="glyphicon glyphicon-plus-sign"></i> </td> 
    </tr> 
    </thead> 
    <tbody> 
    <tr ng-repeat="person in crew"> 
     <td>{{person.name}}</td> 
     <td>{{person.description}}</td> 
     <td><i class="glyphicon glyphicon-edit"></i></td> 
    </tr> 
    </tbody> 
</table> 

답변

1

ng-route를 포함해야합니다.

angular.module('myApp', ['ngRoute']). 

CDN :

http://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-route.min.js

+0

글쎄, 당신에게 선생님 감사합니다. 나는 내가 본 적이있는 모든 자습서에서 구체적으로 포함시키지 않았기 때문에 라우팅이 내장되어 있지 않은 각도의 버전을 발견했다. – wootscootinboogie

+0

그들은 1.2 버전에 포함시키지 않습니다. 그것의 일반적인 문제. – Nix

0

그리고 그것은 그런 식으로 작동합니까?

angular.module('enterprise',[]) 
.config(function($routeProvider){ 
    $routeProvider.when("/",{templateUrl:"/partials/list.html"}) 
}) 
.controller("AppController", ['$scope', 
    function ($scope){ 
     $scope.crew =[ 
      {name:'Picard',description:'captain'}, 
      {name: 'Riker',description:'number 1'}, 
      {name:'Word',description:'Security'} 
     ]; 
    } 
]); 

좋아, 응답이 여기에 있습니다 : AngularJS 1.2 $injector:modulerr

+0

라우팅을 사용하지 않는 한 제대로 작동합니다. – wootscootinboogie

+0

Nix가 맞았습니다. 라우팅 js 파일이 모듈의 종속물로 포함되지 않았기 때문입니다. – wootscootinboogie