Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: No controller: ngModel

When I add ng-change="reverseOrder=this.checked" to a checkbox, as so:

<input id="reverseOrder" type="checkbox" ng-change="reverseOrder=this.checked"/>

I get the following exception:

Error: No controller: ngModel

I've tried adding ng-model to the inputbox, a div wrapping the entire view and in the <html> tag, this produces an exception liek the following:

Error: Non-assignable model expression:  (<div class="ng-scope" ng-model="">)

What's going on here? I didn't think I needed to explicitly pull in the model. I've read the Angular documentation but am none the wiser.

Thanks in advance.

Dave

like image 292
BanksySan Avatar asked Apr 03 '13 13:04

BanksySan


1 Answers

ngChange requires ngModel directive. But you're using ngChange for the same purpose of ngModel. Just go with:

<input id="reverseOrder" type="checkbox" ng-model="reverseOrder"/>
like image 179
Caio Cunha Avatar answered Sep 28 '22 02:09

Caio Cunha