Tuesday, December 10, 2013

trying to learn AngularJS

Today I saw this error:

You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

 
 

This suggested that it came from screwing up an assignment like this:

var assetControllers = angular.module('assetControllers', ['serverServices', 'services',
      'filters']);

 
 

The problem befell me when I broke one Angular module which looked (let's pretend) like so:

angular.module('filters', [])
   .filter('foo', function() {
      return function(input) {
         return input * 2;
      }
   }).filter('bar', function() {
      return function(input) {
         return input * 3;
      }
   });

 
 

...up into to separate files like so:

  1. angular.module('foo', [])
       .filter('foo', function() {
          return function(input) {
             return input * 2;
          }
       });
       

  2. angular.module('bar', [])
       .filter('bar', function() {
          return function(input) {
             return input * 3;
          }
       });

In the HTML file bootstrapping the Angular stuff, I was smart enough to change the script tag I had for the consolidated file into two separate script tags for what became two separate files. (It seems one has to bootstrap modules with script tags as there is not an AMD paradigm.) However, the error I saw came because I had not yet changed the line of code at the very top of this blog posting to:

var assetControllers = angular.module('assetControllers', ['serverServices', 'services', 'foo',
      'bar']);

 
 

I suppose I have a lot to learn. I asked a coworker how he learned AngularJS and he responded that he worked on a project with others in which they pulled the code for what he called the seed project and hammered on it until it became something else they needed. Scott Bellware is tweeting of Angular, at least as of today, and links to tutorials he has offered include:

No comments:

Post a Comment