angular: NgUpgrade "Error: Expecting HostViewFactoryRef for: navbarInfo"

Keep trying to make my first ng2 component in my ng1 app but I got this error.

Error: Expecting HostViewFactoryRef for: navbarInfo
    at directiveFactory (upgrade_adapter.ts:501)
    at Object.invoke (angular.js:4604)
    at angular.js:7475
    at n (angular.js:321)
    at Object.<anonymous> (angular.js:7473)
    at Object.invoke (angular.js:4604)
    at Object.$get (angular.js:4443)
    at Object.invoke (angular.js:4604)
    at angular.js:4403
    at Object.d [as get] (angular.js:4550)
var navbarInfo = ng.core.Component({
  selector: 'navbar-info',
  template: '<h1>Hello Navbar Info!</h1>'
}).Class({
  constructor: function() {
  }
});

var adapter = new ng.upgrade.UpgradeAdapter();
angular.module('Plan.components.navbarInfo', [])
.directive('navbarInfo', adapter.downgradeNg2Component(navbarInfo));
<navbar-info class="col-xs-9 navbar-info"></navbar-info>

thanks

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

I think your downgrading the component after you’ve already bootstrapped. Here is a working example.

http://plnkr.co/edit/WxN4EpYuLf8bf8bzhgKs?p=preview