Last active
April 8, 2016 15:43
-
-
Save jarbitlira/df14cc9212ad4ce1c803ee309d569f29 to your computer and use it in GitHub Desktop.
Controller initialized twice using ngComponentRouter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
angular | |
.module('moduleName') | |
.controller('controllerName', controllerName); | |
controllerName.$inject = []; | |
function controllerName() { | |
var $ctrl = this; | |
$ctrl.isReusable = false; | |
$ctrl.$routerCanReuse = function () { return true; } | |
$ctrl.$routerOnReuse = function (next) { | |
if (!$ctrl.isReusable) { | |
$ctrl.isReusable = true; | |
return false; | |
} | |
$ctrl.isReusable = false; | |
init(next.params); | |
}; | |
$ctrl.$routerOnActivate = function (next) { | |
init(next.params); | |
} | |
function init(params){ | |
//params are the url params | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment