Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript AngularJS Basics (1.x) Using Angular's Built In Directives Using ng-change To Set Data State

Gavin Murphy
Gavin Murphy
10,004 Points

ng-change problem

there seems to be a problem when i add ng-change(""). Every time I add it , everything in the itteration breaks down, I only get the first item and my edit button stops working. And when i remove ng-change it works perfectally. Please help!

Gavin Murphy
Gavin Murphy
10,004 Points

<div class="item" ng-class="{'editing-item' : editing}" ng-repeat="todo in todos"> <input mg-modal="todo.completed" type="checkbox" /> <label ng-hide="editing" ngclick="helloWorld()">{{todo.name}}</label> <input ng-change="learningNgChange" ng-blur="editing = false;" ng-show="editing" ng-modal="todo.name" class="editing-label" type="text" />

            <div class="actions">
                <a href="" ng-click=" editing = !editing">Edit</a>
                <a href="" ng-click="helloWorld()">Save</a>
                <a href ="" class="Delete">Delete</a>
            </div><!--actions-->
        </div>

4 Answers

Seth Kroger
Seth Kroger
56,414 Points

If you're calling a function you need parentheses after the controller function name, so learningNgChange should be learningNgChange().

Gavin Murphy
Gavin Murphy
10,004 Points

Thanks for the quick response man

I already tried that but I just realized that there are three typos

mg-modal supposed to be ng-model LOL

and model again further down.... so funny this has been wrecking my head for ages and as soon as i posted it i found the problem LOL

Gavin Murphy
Gavin Murphy
10,004 Points

I already tried that but I just realized that there are three typos

mg-modal supposed to be ng-model LOL

and model again further down.... so funny this has been wrecking my head for ages and as soon as i posted it i found the problem LOL

Gavin Murphy
Gavin Murphy
10,004 Points

Thanks for the quick response man