showcase: Manually Identify Dependencies with ng-strict-di vs @ngInject
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 20 Aug 2015 00:19:18 +0000 (02:19 +0200)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 20 Aug 2015 00:19:18 +0000 (02:19 +0200)
angularjs/showcase/src/showcase/app/welcome/welcome.controller.js
angularjs/showcase/src/showcase/index.html

index 0b4b304..41ee92f 100644 (file)
@@ -5,8 +5,13 @@
     .module('app.welcome')
     .controller('Welcome', Welcome);
 
+  // When using <div ng-app="app" ng-strict-di> (strict mode) we must always
+  // manually identify dependencies.
+  // Instead I am going to use ngInject because it is cool :)
+  // Welcome.$inject = ['$location'];
+
   /* @ngInject */
-  function Welcome() {
+  function Welcome($location) {
     var vm = this;
 
     vm.hello = 'Hello World';
index 6eb7388..e0c1ced 100644 (file)
          This could be useful when using different frameworks in the same html application where one framework
          works with some DOM elements and another framework works with other DOM elements.
     -->
+    <!-- <div ng-app="app" ng-strict-di>
+        When using ng-strict-di we must manually identify dependencies.
+        For example, Welcome controller, if using strict mode, would require
+        Welcome.$inject = ['$location'];
+
+        Instead I am going to use @ngInject because it is cool.
+    -->
     <div ng-app="app">
       <div>
         <ui-view>