I've another approach to not need always create a new module, here is:
Creating my App module(one time)
(function (angular) {
//creating myApp Module
var myApp = angular.module('myApp', []);
}(angular));
With myApp module created, now i just get it
(function (angular) {
//getting myApp Module
var myApp = angular.module('myApp');
myApp.factory('Items',
function () {
var items = {};
items.query = function() {
// In real apps, we'd pull this data from the server...
return [
{title: 'Paint pots', description: 'Pots full of
paint', price: 3.95},
{title: 'Polka dots', description: 'Dots with
polka', price: 2.95},
{title: 'Pebbles', description: 'Just little
rocks', price: 6.95}
]; };
return items;
});
}(angular));
Same here
(function (angular) {
//getting myApp Module
var myApp = angular.module('myApp');
myApp.controller('ShoppingController', ['$scope', 'Items',
function ($scope, Items) {
$scope.items = Items.query();
}])
}(angular));
This is correct? This is the best way? What you think guys? I think, that
the best way after do this, is to use grunt to combine everything into a
single file.
I'm new to angular, and i'm studying pretty much to learn about this
framework, so any help is welcome.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.