davej / angular-classy

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

update from 0.4.2 to 1.1 #44

Closed idoo closed 9 years ago

idoo commented 9 years ago

After update i have trouble

i define app

@Application = angular.module 'Application', [
  'classy'
  'ui.router'
]

and controller

Application.classy.controller
  name: 'ApplicationCtrl'
  inject: [
    '$scope'
  ]

and call from layout

%body{"ng-controller" => "ApplicationCtrl"}

Result: Image

davej commented 9 years ago

The API is different in 1.x, you can either add the controller methods to the methods object (as seen on http://davej.github.io/angular-classy/) or use the classy-compat plugin: https://github.com/davej/classy-compat

davej commented 9 years ago

Although... the errors in your console indicate that you haven't added Classy to your app.

Please ensure that the script is after the angular script and that the path is correct, e.g.

<script src="bower_components/angular-classy/angular-classy.min.js"></script>

And that you have added classy to your modules

var app = angular.module('app', ['classy']);
idoo commented 9 years ago

@davej i add classy (you can see in first post) i define app

@Application = angular.module 'Application', [
  'classy'
  'ui.router'
]
davej commented 9 years ago

@Application (this.Application) is not necessarily the same as Application, it depends on the function context in which it is created and whether or not you are using strict mode ("use strict";) javascript.

If you can give me access to the page where this error is occurring, or recreate this in plunker/jsbin then I could have a look, otherwise it's difficult to debug just from a few lines of code.

davej commented 9 years ago

It is probably safer (less context dependent) to use window.Application = angular.module 'Application', ['classy', 'router'] by the way.

idoo commented 9 years ago

@davej sorry, i can't give access for you :( i tried use window.Application and Application — no luck :(

davej commented 9 years ago

Ok, I can't really help if I can't recreate the issue unfortunately. There is not enough info for me to help you debug this issue. Sorry.

idoo commented 9 years ago

@davej when i stop app, Application has only .classyController property, not .classy maybe it's help understand what is wrong?

davej commented 9 years ago

That sounds like a very old version of Classy (maybe 0.3). Can you make sure that you are using the correct angular-classy JS file as found in the latest release https://github.com/davej/angular-classy/releases/tag/v1.1.0

idoo commented 9 years ago

@davej :+1: i get from rails-assets, when i change version from zip - work correctly!