Code Monkey home page Code Monkey logo

Comments (5)

bengotow avatar bengotow commented on May 22, 2024

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.

ekettoz avatar ekettoz commented on May 22, 2024

@bengotow

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.

ekettoz avatar ekettoz commented on May 22, 2024

@bengotow @faroe228

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.

bengotow avatar bengotow commented on May 22, 2024

@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.

petebacondarwin avatar petebacondarwin commented on May 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.