Hello All,

I cannot figure out whats going on with my routes and template

I have with yellow marked section. I cannot get new.html rendered. It looks 
like it's calling $http all the time, but that one should be called only 
when form is submitted (form may be wrong too, didnt have chance to have a 
look at it as it never rendered). It loos like it is rendering 
showController based what i see in browser.

I'm very beginner with angular and cannot get my head around it whats going 
on here.

Thanks for any advices.

Roman

my files:

# routes.js
angular.module('NoteWrangler')

.config(function($routeProvider){
    $routeProvider.when('/notes', {
        templateUrl: 'templates/pages/notes/index.html',
        controller: 'NotesIndexController',
        controllerAs: 'indexController'
    })
    .when('/notes/:id', {
        templateUrl: 'templates/pages/notes/show.html',
        controller: 'NotesShowController',
        controllerAs: 'showController',
    })
    .when('/notes/new', {
        templateUrl: 'templates/pages/notes/new.html',
        controller: 'NoteCreateController',
        controllerAs: 'createController',
    })
    .when('/users', {
        templateUrl: 'templates/pages/users/index.html',
    })
    .when('/', {
        templateUrl: 'templates/pages/notes/index.html',
    })
    .otherwise( { redirectTo: '/' });
});


# notes-create-controller.js

angular.module('NoteWrangler')
.controller('NoteCreateController', ['$http',function($http){
    var controller = this;
    this.saveNote = function(note) {
        controller.errors = null;
        $http({method: 'POTS', url: 'http://localhost:3000/notes.json', data: 
note})
        .catch(function(note){
            controller.errors = note.data.error;
        });
    };
}]);


# new.html

<h1>New Note</h1>

<p ng-if="createController.errors"> {{createController.errors}} </p>

<div class="new-note">
    <div class="new-note-container">
        <form class="form"
              ng-controller="createController as createCtrl"  novalidate>
            <fieldset>
                <label for="title">Title</label>
                <input ng-model='createCtrl.note.title' name="title" />
            </fieldset>

            <fieldset>
                <label for="description">Description</label>
                <textarea name="description" 
ng-model="createCtrl.note.description"></textarea>
            </fieldset>

            <fieldset>
                <label for="content">Content</label>
                <textarea ng-model='createCtrl.note.content' 
name="content"></textarea>
            </fieldset>

            <button class="btn" 
ng-click="createCtrl.saveNote(note)">Save</button>
        </form>
    </div>
</div>

-- 
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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to