I am new to AngularJS and I created a simple application that has the following pages.
1) index.html
2) View1.html
3) View2.html
The problem I encountered is the routing of the application in View1 and View2. No output and browser. After some research, I realized that from Angular version 1.2 a separate angular -route.js "file should be added ahead, which I did but did not get any help. Can you look at that and provide a solution.
PS: I am new to Angular, so pls save me if I make some small mistakes.
Here is my code.
index.html
<html data-ng-app="demoApp"> <head> <title>Using AngularJS Directives and Data Binding</title> <meta charset="UTF-8"> <script src="Scripts/angular.js"></script> <script src="Scripts/angular-route.js"></script> </head> <body> <div> <div data-ng-view=""></div> </div> <script> var demoApp = angular.module('demoApp',['ngRoute']); demoApp.config(function($routeProvider){ </script> </body>
View1.html
<div class="container"> <h2>View 1</h2> Name: <br /> <input type="text" data-ng-model="filter.name" /> <br /> <ul> <li data-ng-repeat="cust in customers | filter:filter.name | orderBy:city "> {{cust.name | uppercase}} - {{cust.city | lowercase }}</li> </ul> <br /> Customer Name:<br /> <input type="text" data-ng-model="newCustomer.name" /> <br /> Customer City:<br /> <input type="text" data-ng-model="newCustomer.city" /> <br /><br /> <button data-ng-click="addCustomer()">Add Customer</button> <br /><br /> <a href="#/view2">View 2</a>
View2.html
<div class="container"> <h2>View 1</h2> City: <br /> <input type="text" data-ng-model="city" /> <br /> <ul> <li data-ng-repeat="cust in customers | filter:city | orderBy:name "> {{cust.name | uppercase}} - {{cust.city | lowercase }}</li> </ul>
Rajat source share