Skip to content

ngRoute not working. is there something i am doing wrong. #5

@shahakshit

Description

@shahakshit
<title>a</title> <script src="Scripts/angular.min.js" type="text/javascript"></script> <script src="Scripts/angular-route.min.js" type="text/javascript"></script> <script type="text/javascript"> var App = angular.module('App', ['ngRoute']);
        App.config(function ($routeProvider) {                
            $routeProvider
                .when('/', { templateUrl: 'Partials/View1.htm', controller: 'SimpleController' })
                .when('/partial2', { templateUrl: 'Partials/View2.htm', controller: 'SimpleController' })
                .otherwise({ redirectTo: '/AJTest' });
        });

        App.controller('SimpleController', function ($scope) {
            $scope.customers =
                                [
                                    { name: 'a', city: 'a' },
                                    { name: 'b', city: 'b' },
                                    { name: 'c', city: 'c' },
                                    { name: 'd', city: 'd' }
                                ];
            $scope.addCustomer = function () {
                $scope.customers.push({ name: $scope.newCustomer.name, city: $scope.newCustomer.city });
            }
        });

    </script> 
    <div data-ng-controller="SimpleController">
        Name :<br /> 
        <input type="text" data-ng-model="name" />  {{ name }}    
        <ul>
            <li data-ng-repeat="cust in customers | filter:name | orderBy:city">{{ cust.name  + ' ' + cust.city}} </li>
        </ul>
    </div>                                
</body>
---------------------**********************************************---------------------------------------- Partials\View1.htm goes like this.

View 1

Name :

  • {{ cust.name }}

CustomerName : CustomerCity : Add Customer

Please help. thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions