Tutorial 15.1 Basic Module

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

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

 
</head>
<body >
  <div ng-app="myApp">
  <div>
    {{ 'World' | greet }}
  </div>
</div>
</body>
</html>


******************************************INDEX.HTML*****************************************************
********************************************script.js***************************************************
(function(angular) {
  'use strict';
// declare a module
var myAppModule = angular.module('myApp', []);

// configure the module.
// in this example we will create a greeting filter
myAppModule.filter('greet', function() {
 return function(name) {
    return 'Hello, ' + name + '!';
  };
});
})(window.angular);
********************************************script.js***************************************************
******************************************Protractor.js*****************************************************
it('should show off bindings', function() {
  var containerElm = element(by.css('div[ng-controller="Controller"]'));
  var nameBindings = containerElm.all(by.binding('name'));

  expect(nameBindings.count()).toBe(5);
  nameBindings.each(function(elem) {
    expect(elem.getText()).toEqual('Max Karl Ernst Ludwig Planck (April 23, 1858 – October 4, 1947)');
  });
});
******************************************Protractor.js*****************************************************

it('should add Hello to the name', function() {
  expect(element(by.binding("'World' | greet")).getText()).toEqual('Hello, World!');
});
******************************************Protractor.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