I am studying AngularJS and met the problem with my, actually, hello world app. At first I will show the code:
index.html
<!DOCTYPE html>
<html ng-app="nazwa">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<a href = "#">Add Order</a>
<div>
<div ng-view></div>
</div>
<script src="scripts/angular.min.js"></script>
<script src="app.js"></script>
</body>
</html>
app.js
var mainModule = angular.module("nazwa", []);
mainModule.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when('/', {
controller: 'customerController',
templateUrl: 'partials/View1.html'
})
.when('/cos', {
controller: 'customerController',
templateUrl: 'partials/View2.html'
})
.otherwise({
redirectTo: '/'
});
}]);
mainModule.controller('customerController', function ($scope) {
$scope.customers = [
{name: 'john', lastname: 'dersky'},
{name: 'someone', lastname: 'lastname'},
{name: 'peter', lastname: 'dewski'}
];
$scope.addCust = function () {
$scope.customers.push(
{name: $scope.newCust.name, lastname: $scope.newCust.lastname}
)
}
});
View1.html
<div class="container">
<h2>View 1</h2>
Name:<br/>
<input type="text" ng-model="filter.name"/><br/>
<ul>
<li ng-repeat="cust in customers | filter:filter.name">{{cust}}</li>
</ul>
<br/>
Customer Name:<br/>
<input type="text" ng-model="newCust.name"/><br/>
Customer Lastname:<br/>
<input type="text" ng-model="newCust.lastname"/><br/>
<button ng-click="addCustomer()">Add</button>
<br/>
<a href="#/cos">View 2</a>
</div>
And View2.html is pretty the same, but few changes
And the problem is that when I run index.html nothing shows. Even if I add some {{1+2}} code to index.html, the browser shows raw "{{1+2}}" rather than "3". When I comment whole routing (mainModule.config) then {{1+2}} works fine and shows 3, but index.html still show neither View1 nor View2
What causes the problem? I have searched whole web, for hours and nothing.. what a shame
thanks for you help and dont beat me too hard for my mistakes, I am quite new in Angular :)
edit:
I found the console log errors:
http://i57.tinypic.com/2e5qgeh.jpg
