Basic angular template

Download script from https://code.angularjs.org/1.3.14/angular.js and name it as angularjs.js in your folder

index.html:

<!DOCTYPE html>
<html>
  <head>
    <script  src=”angularjs.js”></script>
  </head>
  <body>
 <div ng-app=”myApp”>
    <div ng-controller=”AvengersCtrl”><div ng-show=”true”>{{1+2}}</div>
        <input type=”text” ng-model=”search.$” />
        <table>
            <tr ng-repeat=”actor in avengers.cast | filter:search”>
                <td>{{actor.name}}</td>
                <td>{{actor.character}}</td>
                {{name}}
            </tr>
        </table>
    </div>
</div>
<script type=”text/javascript”>
  myApp.controller(‘AvengersCtrl’,function($scope){
   $scope.name =’TEST NE’;
  });
</script>
<script src=”script.js”></script>
</body>
</html>
You can use either inside script for using controller or even an external script like as follows..
var myApp = angular.module(‘myApp’, []);
// myApp.factory(‘Avengers’, function () {
//     var Avengers = {};
//     Avengers.cast = [
//         {
//         name: “Robert Downey Jr.”,
//         character: “Tony Stark / Iron Man”
//         },
//         {
//         name: “Chris Evans”,
//         character: “Steve Rogers / Captain America”
//         },
//         {
//         name: “Mark Buffalo”,
//         character: “Bruce Banner / The Hulk”
//         }
//     ];
//     return Avengers;
// })
myApp.controller(‘AvengersCtrl’,[‘$scope’,function($scope){
    $scope.name=”thoufeeq”;
}]);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s