Tuesday 15 September 2015

javascript - Angular and requirejs, provider with injectors -


I had a working version of my app, which I was now trying to split into needjs module. I'm having some problems, which are some injectors to work for a provider. It seems that when I brought it in need of JS, it does not want to inject my provider properly.

Define this provider -

  ('test / myprovider', ['angular', 'test / my-factory'], my provider (angular, Meritator) function {var metadata = {componentName: 'myProvider', module name: 'test.myProvider'}; var $ moduleObjectProvider; $ module object provider. $ Injection = []; $ module object provider = function () {var trackConstructor = }; This.moduleConstructor = function (name, cb) {// constructor}; var $ get; $. $ Get = $ get; $$ {= URLfactory, $ $ location} var1, var2) {}, function 3: Function () {}};}; }; //metadata.componentName? Angular.module (metadata.modulename, []). Provider (Metadata Data Entry Name, $ moduleObjectProvider); Return metadata; }  

);

The problem I have is with the injector -

  TypeError: line containing '$ Inject' which is mandatory  

Indicates

  $ moduleObjectProvider $ Inject = [];  

One thing worth mentioning I changed the format of the top bits (JSL was screaming at me) when it was the last time changing in needjs format, then the top bit looked like this :

  $ moduleObjectProvider $ Inject = []; Function $ moduleObjectProvider () { 

It seems that everything is fine, the injector has a problem here (I think). I have hit a wall here - if someone could put some light on the situation then it would be nice. Thanks!

Because your var myFunction = function () {} function at the top 'Not hoisted', so when setting the $ Inject array, it is undefined, change it to function myFunction () {} and you should be OK.


No comments:

Post a Comment