Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Feature Request - Add json supplied content to the partial sample pages. #56

Closed
faroe228 opened this issue Mar 26, 2013 · 5 comments
Closed

Comments

@faroe228
Copy link

The feature request:

Add json supplied content to the partial sample pages partial1.html and partial2.html

would be helpful for angular beginners such as myself. Just when I got excited about doing neat things with Angular, Groovy and Gradle using the Gradle Jetty Plugin (and was using groovlets to create JSON for a web UI) ... I read a better practice would be to use the angular-seed app as a starting template ... now it seems I have to start all over again to learn new secret handshakes to get back where I was.

I have not had much luck finding working examples of creating UI content from json based off of using angular-seed as a starting point (there are some jsfiddle and plunker examples but they don't seem to follow the angular-seed file and directory layout).

Hopefully the book market will jump on the Angular bandwagon soon and we will start to see plenty of Angular examples using angular-seed.

Update (next day): After learning more about angular (and a lot of trial and error) I did find a way to create content in the partial pages based on dynamic json from a groovlet ... but I seriously doubt I'm following best practices (much more to learn). The nice thing about using Gradle for any kind of web demo (including angular) is that it is probably one of the easiest ways to share a working web demo without requiring a user to install or configure anything (including gradle when using gradlew - the only catch is that it needs a Java JDK to be present which is extremely simple to install [1 click to download and a double click to start the installer and just use default options]).

@bengotow
Copy link

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!

@ekettoz
Copy link

ekettoz commented Apr 17, 2013

@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!'; }]);

@ekettoz
Copy link

ekettoz commented Apr 17, 2013

@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

@bengotow
Copy link

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

@petebacondarwin
Copy link
Member

The aim is to keep angular-seed as lightweight as possible. Please use angular-phonecat for examples of more complex angular usage.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants