Skip to content Skip to sidebar Skip to footer

Controller Function In Angularjs?

I am new to angular js Controller is not working correctly in my code i am trying to run following code

Solution 1:

You are missing to add value in your ng-app directive that tell angular to run demoApp module on the page.

ng-app="demoApp"

Solution 2:

You should add the name of your app.

ng-app="demoApp"

var demoApp = angular.module('demoApp', []);

  demoApp.controller('SimpleController', function($scope) {
    $scope.customers = [{
      name: 'John Smith',
      city: 'kashipur'
    }, {
      name: 'John fds',
      city: 'san francisko'
    }, {
      name: 'shubham',
      city: 'giarhineg'
    }, {
      name: 'batra',
      city: 'world'
    }];
  });
<scriptsrc="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="demoApp">
  name
  <br /><divdata-ng-controller="SimpleController"><inputtype="text"data-ng-model="name" />{{name}}

    <ul><lidata-ng-repeat="cust in customers | filter:name | orderBy:city">{{cust.name | uppercase}}-{{cust.city | lowercase}}</li></ul></div></div>

Post a Comment for "Controller Function In Angularjs?"