저는 Angular.Js를 배우려고하고 있으며 자습서를 보면서 여기에 붙어 있습니다. 방금 다음 코드로 데모 앱을 만들었습니다. 다음 오류가 발생합니다. 어떤 도움이라도 대단히 감사하겠습니다. 수정 @charlietfi에 대한routingProvide not found AngularJs
Error: [$injector:modulerr] Failed to instantiate module demoApp due to: [$injector:unpr] Unknown provider: $routeProvider
<!doctype html>
<html lang="en" data-ng-app="demoApp">
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<!-- Placeholder for views -->
<div>
<div data-ng-view=""> </div>
</div>
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<script>
var demoApp = angular.module('demoApp',[]);
demoApp.config(function ($routeProvider){
$routeProvider
.when('/',
{
controller: 'SimpleController',
templateUrl: 'partials/view1.html'
})
.when('/view2',
{
controller: 'SimpleController',
templateUrl: 'partials/view2.html'
})
.otherwise({
redirectTo: '/'
})
});
function SimpleController($scope)
{
$scope.customers=[
{name:'AB',city:'Glasgow', cash:20},
{name:'CD',city:'United States', cash:30},
{name:'EF',city:'India', cash:40}
];
$scope.addCustomer = function(){
$scope.customers.push({
name: $scope.newCustomer.name,
city: $scope.newCustomer.city,
cash: $scope.newCustomer.cash
});
};
}
demoApp.controller('SimpleController', SimpleController);
</script>
</body>
</html>
view1.html
<div class="container">
<h2>View1</h2>
</br>
Name:
<br/>
<input type="text" data-ng-model="filter.name" />
</br>
<ul>
<li data-ng-repeat="cust in customers | filter:filter.name"> {{ cust.name }} - {{ cust.city }} - {{ cust.cash | currency:{£} }} </li>
</ul>
</br>
Customer name: </br>
<input type="text" dta-ng-model="newCustomer.name" />
</br>
City: </br>
<input type="text" data-ng-model="newCustomer.city" />
</br>
Cash: </br>
<input type="text" data-ng-model="newCustomer.cash" />
</br>
<button type="button" data-ng-click="addCustomer()" value="Add Customer" />
<a href="#/view2">View 2</a>
</div>
외부 비 핵심 모듈을 사용하는 경우 당신이 당신의 주요 모듈을 만들 때이 빈 배열 종속성으로 추가해야 각도-route.js을 포함한다. 당신이'routing-js'가로드되는 것을 봅니다. 외부 모듈 인 경우 의존성으로 주입해야합니다. – charlietfl
@charlietfl great ... 그게 문제를 해결했습니다. – Deep
그래, 그들은 1.0에서 core 사이의 라우팅 비트를 분리했습니다. 8 및 1.2. 1.0.8로 전환해도 문제는 해결되었지만 1.2 분기에 머물러있는 것이 좋은 생각입니다. 릴리스가 가까워 보이는 것 같습니다. – ivarni