Sabtu, 13 Februari 2016

angularJS 3

index
<!doctype html>
<html lang="en" ng-app="phonecatApp">
<head>
 <meta charset="utf-8">
 <title>Google Phone Gallery</title>
 <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
 <link rel="stylesheet" href="css/app.css">
 <script src="bower_components/angular/angular.js"></script>
 <script src="js/controllers.js"></script>
</head>
<body ng-controller="PhoneListCtrl">

 <div class="container-fluid">
 <div class="row">
 <div class="col-md-2">
 <!--Sidebar content-->

 Search: <input ng-model="query">
 Sort by:
 <select ng-model="orderProp">
 <option value="name">Alphabetical</option>
 <option value="age">Newest</option>
 <option value="-age">Oldest</option>
 </select>
 <p>order by : {{orderProp}}</p> </div>
 <div class="col-md-10">
 <!--Body content-->

 <ul class="phones">
 <li ng-repeat="phone in phones | filter:query | orderBy:orderProp">
 <span>{{phone.name}}</span>
 <p>{{phone.snippet}}</p>
 </li>
 </ul>

 </div>
 </div>
 </div>

</body>
</html>
 
 

controller
'use strict';

/* Controllers */

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

phonecatApp.controller('PhoneListCtrl', function($scope) {
  $scope.phones = [
    {'name': 'Nexus S',
     'snippet': 'Fast just got faster with Nexus S.',
     'age': 1},
    {'name': 'Motorola XOOM™ with Wi-Fi',
     'snippet': 'The Next, Next Generation tablet.',
     'age': 2},
    {'name': 'MOTOROLA XOOM™',
     'snippet': 'The Next, Next Generation tablet.',
     'age': 3}
  ];

  $scope.orderProp = 'age';
});       
 

aaa

aaa

angularJS 2

index
<!doctype html>
<html lang="en" ng-app="phonecatApp">
<head>
 <meta charset="utf-8">
 <title>Google Phone Gallery</title>
 <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css">
 <link rel="stylesheet" href="css/app.css">
 <script src="bower_components/angular/angular.js"></script>
 <script src="js/controllers.js"></script>
</head>
<body ng-controller="PhoneListCtrl">

 <div class="container-fluid">
 <div class="row">
 <div class="col-md-2">
 <!--Sidebar content-->

 Search: <input ng-model="query">

 </div>
 <div class="col-md-10">
 <!--Body content-->

 <ul class="phones">
 <li ng-repeat="phone in phones | filter:query">
 <span>{{phone.name}}</span>
 <p>{{phone.snippet}}</p>
 </li>
 </ul>

 </div>
 </div>
 </div>

</body>
</html>

 

controller
'use strict';

/* Controllers */

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

phonecatApp.controller('PhoneListCtrl', function($scope) {
  $scope.phones = [
    {'name': 'Nexus S',
     'snippet': 'Fast just got faster with Nexus S.'},
    {'name': 'Motorola XOOM™ with Wi-Fi',
     'snippet': 'The Next, Next Generation tablet.'},
    {'name': 'MOTOROLA XOOM™',
     'snippet': 'The Next, Next Generation tablet.'}
  ];
});       
 

aaa

aaa

aaa

angularJS 1

index.html
       <html ng-app="phonecatApp">
<head>
  ...
  <script src="bower_components/angular/angular.js"></script>
  <script src="js/controllers.js"></script>
</head>
<body ng-controller="PhoneListCtrl">

  <ul>
    <li ng-repeat="phone in phones">
      <span>{{phone.name}}</span>
      <p>{{phone.snippet}}</p>
    </li>
  </ul>

</body>
</html>

       
 

app/js/controllers.js
var phonecatApp = angular.module('phonecatApp', []);

phonecatApp.controller('PhoneListCtrl', function ($scope) {
  $scope.phones = [
    {'name': 'Nexus S',
     'snippet': 'Fast just got faster with Nexus S.'},
    {'name': 'Motorola XOOM™ with Wi-Fi',
     'snippet': 'The Next, Next Generation tablet.'},
    {'name': 'MOTOROLA XOOM™',
     'snippet': 'The Next, Next Generation tablet.'}
  ];
}); 
 

aa

aa

aa

aa