Tutorial 3.2 Spicy Argument

******************************************INDEX.HTML*****************************************************
<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example - example-controller-spicy-2-production</title>
 

  <script src="//code.angularjs.org/snapshot/angular.min.js"></script>
  <script src="app.js"></script>
 

 
</head>
<body ng-app="spicyApp2">
  <div ng-controller="SpicyController">
 <input ng-model="customSpice">
 <button ng-click="spicy('chili')">Chili</button>
 <button ng-click="spicy(customSpice)">Custom spice</button>
 <p>The food is {{spice}} spicy!</p>
</div>
</body>
</html>

******************************************INDEX.HTML*****************************************************
********************************************APP.JS***************************************************
(function(angular) {
  'use strict';
var myApp = angular.module('spicyApp2', []);

myApp.controller('SpicyController', ['$scope', function($scope) {
    $scope.customSpice = 'wasabi';
    $scope.spice = 'very';

    $scope.spicy = function(spice) {
        $scope.spice = spice;
    };
}]);
})(window.angular);
********************************************APP.JS***************************************************

Comments

Popular posts from this blog

Tutorial 12.12 Creating a Directive that Wraps Other Elements 3

Tutorial 12.14 Creating Directives that Communicate