JSFiddle - React, Tailwind, and code Playground
by Nathaniel Anderson
HTML
<div>
<div ng-controller="MyCtrl">
Hello, {{ name }}
</div>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
myApp.factory('hi', function(){
console.log('hi');
return {v:'hi'};
})
myApp.controller('MyCtrl', ['$scope', 'hi', 'hi2', function($scope, hi, hi2) {
$scope.name = 'Superhero';
}])
myApp.controller('MyCtrl2', ['$scope', function($scope){
}]);
//Doesn't work, hi2 not declared before bootstrapped
//angular.bootstrap(document, ['myApp']);
//You cannot add controllers, services, directives, etc after an application bootstraps.
//https://docs.angularjs.org/guide/bootstrap
myApp.factory('hi2', function(){
console.log('hi2');
return {v:'hi2'};
})
//Does work, if bootstrap after declaring the factory:
angular.bootstrap(document, ['myApp']);
//https://jsfiddle.net/cattails27/6mcck6pp/
//http://jsfiddle.net/elussich/pw5296ym/