Comments (5)
I agree that the angular-seed should really include an angular resource. I'm trying to add a resource to the seed project right now, and I'm having quite a bit of trouble because the syntax used for the controllers doesn't match the documentation at http://docs.angularjs.org/guide/dev_guide.mvc.understanding_controller, and the services.js file is laid out differently as well. I'm not sure which is older, or if both are correct. Either way, I'd be nice to have a resource in the template!
from angular-seed.
If I'm not mistaken the syntax for the controllers follows the rules as described in the document you referenced. Notice the paragraph 'Setting up the initial state of a scope object':
Many of the examples in the documentation show the creation of functions in the global scope. This is only for demonstration purposes - in a real application you should use the .controller method of your Angular module for your application as follows:
var myApp = angular.module('myApp',[]);
myApp.controller('GreetingCtrl', ['$scope', function($scope) { $scope.greeting = 'Hola!'; }]);
from angular-seed.
If you're learning about Angular, and need to know about resources, and writing a service to access Restfull services have a look at 'Step 11' of the AngularJS tutorial. It provides code on how to achieve this:
http://docs.angularjs.org/tutorial/step_11
from angular-seed.
@ekettoz —thanks for the info! I was definitely confused about the examples on those pages that use the global scope. Wrapping the controllers into a module definitely makes sense for a larger project. Once I realized that the ".controller" approach does dependency injection using the ['$scope', function($scope) {… syntax I was able to get my resources working. I'll check out that tutorial and make sure I'm doing it right, though!
Thanks—sorry to pollute this ticket with my problems ;-) I think it would definitely be helpful to throw this into the seed.
from angular-seed.
The aim is to keep angular-seed as lightweight as possible. Please use angular-phonecat for examples of more complex angular usage.
from angular-seed.
Related Issues (20)
- No longer works HOT 16
- while installing npm install -g @angular/cli i'm getting this error HOT 1
- install failed HOT 3
- npm start is not working HOT 1
- Running test.bat outputs this error "TypeError: Cannot read property 'prototype' of undefined" HOT 1
- Not at all installing HOT 1
- Running test.bat from https://github.com/angular/angular-seed/tree/69c9416c8407fd5806aab3c63916dfcf0522ecbc" outputs "TypeError: Cannot read property 'prototype' of undefined" HOT 1
- Not able to inject service in controller HOT 1
- npm start issue HOT 1
- Unable to Access HOT 2
- Missing instructions for how to update to angularjs 1.7 HOT 1
- Is it just me or autoreload feature is missing? HOT 1
- What is the reason to server on localhost, as opposed to default 0.0.0.0? HOT 1
- Bundle CSS preprocessor please HOT 1
- npm install error HOT 6
- fail to install ui-bootstrap HOT 1
- Error npm run protractor HOT 1
- SyntaxError: Use of const in strict mode. HOT 1
- Issue with npm run protractor HOT 1
- Install failing on node-pre-gyp dependency
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 angular-seed.