Comments (6)
ngmin looks for calls to controller, etc. on an object created with angular.module
, and it's pretty specific about this lookup. There was a similar issue here.
In an older Coffee project that I worked on, we did something like this:
#= require ../app
# create an object that references our module
app = angular.module 'spokenvote'
app.controller 'MyController', ($scope ... ) ->
This issue has come up a few times in the ngmin issue tracker, and it seems unlikely that it will be changed.
from ngmin-rails.
Thank you!
Just for clarity, I'm currently bootstrapping my app like so:
window.App = angular.module('spokenvote', [ 'ngRoute', 'spokenvote.services', 'spokenvote.directives', 'ui', 'ui.bootstrap' ]).config(appConfig)
servicesConfig = ['$httpProvider', ($httpProvider) ->
$httpProvider.responseInterceptors.push('errorHttpInterceptor')
]
App.Services = angular.module('spokenvote.services', ['ngResource', 'ngCookies']).config(servicesConfig).run(['$rootScope', '$location', ($rootScope, $location) -> $rootScope.location = $location])
App.Directives = angular.module('spokenvote.directives', [])
Following your guidance and testing I do see that structuring my controllers with:
App = angular.module "spokenvote"
App.controller 'UserSettingsCtrl', ($scope, $modalInstance, CurrentUser) ->
......
Does appear to get ngmin correctly annotating the DI.
So do I need this App = angular.module "spokenvote"
in every controller then? I can't place that or configure things to make that App = angular.module "spokenvote"
line reusable?
from ngmin-rails.
From what I recall, I wasn't able to get anything except a direct call to angular.module
per-file to work correctly. It's possible if you use CoffeeScript's "bare" mode that you could have one invocation at the top of the concatenated file, but I think you'd have to do something special for dev mode.
from ngmin-rails.
Ok, but the App = angular.module "spokenvote"
line is just pointing to my app, not calling another copy of it, right? And that's not somehow overlapping or convoluting my existing bootstrap? Since my existing bootstrap already refers to App, should I be calling it app or something distinct for clarity?
from ngmin-rails.
That's correct--angular.module
with only one parameter gets a reference to that module instead of creating a new module.
As far as the App
variable, CoffeeScript will wrap each file in an IIFE, so the variables won't collide.
from ngmin-rails.
Thanks so much!!
/k
On Mar 26, 2014, at 2:19 PM, Brandon Tilley [email protected] wrote:
That's correct--angular.module with only one parameter gets a reference to that module instead of creating a new module.
As far as the App variable, CoffeeScript will wrap each file in an IIFE, so the variables won't collide.
—
Reply to this email directly or view it on GitHub.
from ngmin-rails.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngmin-rails.