最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error: No controller: ngModel - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question edited Apr 3, 2013 at 15:21 BanksySan asked Apr 3, 2013 at 13:19 BanksySanBanksySan 28.5k36 gold badges125 silver badges229 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 14

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"/>
发布评论

评论列表(0)

  1. 暂无评论