davej / angular-classy

Cleaner class-based controllers with Angular 1
http://davej.github.io/angular-classy/
813 stars 27 forks source link

app constants? #33

Closed vwal closed 9 years ago

vwal commented 9 years ago

Hi,

Is it possible to use constants with angular-classy? I tried creating a constant (with .constant), and then injected ito th the classy controller (like I could inject a constant into a standard Angular controller). But the constant appears 'undefined' within the classy controller.

Thakns for any insights on this!

Ville

davej commented 9 years ago

I would have assumed it should work, can you show me the code your using.

davej commented 9 years ago

Also please let me know the version of Classy your using.

vwal commented 9 years ago

It might well work.. I've been looking at AngularJS for the past week, and still try to wrap my head around it :-). Hence, I might just be using it wrong; I couldn't find too many examples of using Classy with different aspects of AngularJS (such as constants). My embarresing exploratory code is available on Plunker. The version of Classy is 1.0.0 beta2.

When I click on 'testing', I get an error on the console: "TypeError: Cannot read property 'facebook' of undefined".

Another question I have is regarding (on my test code) the "testr" function. It it doesn't seem to be available the scope. Perhaps I've misunderstood how functions should automatically be added on the $scope. Would you have a further example available?

Thanks for your help!

wuxiaoying commented 9 years ago

http://plnkr.co/edit/kHMQfS7j7bGZV4q1M0m2?p=preview

Few things to note:

Hope this helps :)!

davej commented 9 years ago

I was beaten to it by @wuxiaoying. :-)

My fork is pretty much the same: http://plnkr.co/edit/mBFTcl54CltGa5kwVyFO?p=preview

vwal commented 9 years ago

Thank you both for the replies. They were very helpful!