Skip to content

$onInit and $onDestroy are not called when adding/removing components to the view #5

@TomMcQuarrieOTH

Description

@TomMcQuarrieOTH

Components added to the page via bicker do not trigger the onInit and onDestroy functions. I see in other routers like angular-ui-router, there is code to specifically call these functions:
https://github.com/angular-ui/ui-router/blob/eab98462a6df5fd8a5001ae5e282a7e227ce010e/src/ng1/directives/viewDirective.ts#L408

Code to reproduce:

var app = angular.module('bicker_example', ['bicker_router']);

var testController = function(){
  console.log('Construct');
  this.$onInit = function(){
    console.log('Init');
  };
  this.$onDestroy = function(){
    console.log('Destroy!');
  }
};

app.component('testComponent', {
  templateUrl: 'test.html',
  controller: testController
});

app.config(function (RouteProvider, ViewBindingsProvider) {

  RouteProvider.registerUrl('/', { state: { view: { test: true }}});

  ViewBindingsProvider.bind('main', [{
    requiredState: ['view.test'],
    component: 'testComponent'
  }]);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions