iamdash iamdash - 3 months ago 14
AngularJS Question

Angular 1.5 component not seeming to register

I am currently writing an app using Angular 1.5's

method. My component code is as follows:

(function () {
'use strict';

function controllerFn($state) {

console.log('controllerFn'); // this logs fine
this.testVar = 'test me';

this.onLoadComplete = function () {
console.log('load completed')


APP.component('appPreloader', {
controller: controllerFn,
controllerAs: 'appPreloader'


and my template code is as follows:

<app-preloader class="page-preloader">
<preloader on-complete="appPreloader.onLoadComplete"></preloader>

The issue I am having is that
in my view is empty, and for example,
renders nothing.

I know this is related to
's isolate scope, but I am pretty stumped as to how I should be setting this up for everything to work as should.

Any advice much appreciated.



Unless you have template/templateUrl with component/directive, the content which resides inside directive/component that part of DOM would not compiled with component context. You should have that inner HTML in your component inside component template so that it would get compiled with component context.

Checkout Plunkr Here, here you can see inside app-preloader you can access the variables(context) of mainCtrl.

Whereas if you can check this plunkr I just moved the inner html of component directly to the component template property which started working.