real
real

Reputation: 491

Javascript ngModel: No value accessor for ''

I'm using plain javascript instead of TypeScript in a simple Angular 2 Get Started example with [(ngModel)], as shown below. It's giving me EXCEPTION: No value accessor for ''.

<!doctype html>
<html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.11/angular2-polyfills.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.11/Rx.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.11/angular2-all.umd.min.js"></script>
<script>
(function(app) {
  app.AppComponent = ng.core.Component({
    selector: 'my-div',
    template: '<h1>Hello {{obj.a}}</h1>' + 
      '<div><input type="text" [(ngModel)]="obj.a"/></div>',
  }).Class({
    constructor: function() {
      this.obj = {a: "World"};
    }
  });
})(window.app || (window.app={}));

(function(app) {
  document.addEventListener('DOMContentLoaded', function() {
    ng.platform.browser.bootstrap(app.AppComponent);
  });
})(window.app || (window.app={}));
</script>
<body>
<my-div></my-div>
</body>
</html>

The error is produced with 2.0.0-beta.1 to 2.0.0-beta.11. If I were to use the original 2.0.0-beta.0, the above code runs without error.

I believe this is a bug with latest version of Angular 2. I wish I'm wrong, but no feature change should break something that works in 2.0.0-beta.0.

Here's plnkr: https://plnkr.co/edit/CqSeXeBpXgfgJUvBQ4mP?p=preview

Upvotes: 0

Views: 907

Answers (1)

real
real

Reputation: 491

As per Eric Martinez, I just needed to use angular2-all.umd.dev.js instead of angular2-all.umd.min.js.

<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/2.0.0-beta.11/angular2-all.umd.dev.js"></script>

That 1.0MB file though...

Upvotes: 1

Related Questions