Yes, you can share the view related common code using $controller
. Check my answer for the same here. https://stackoverflow.com/a/27868095/3292746
If you are using controllerAs syntax, we can share the code in better way by just using class implementation in javascript.
For example:
function CommonCtrl(){
this.commonMethod = function(){
}
}
And in your controller
// __extends code is copied from typescript transpiled code.
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var AppCtrl = (function(_super){
__extends(AppCtrl, _super);
function AppCtrl(){
_super.call(this); // calling CommonCtrl constructor.
this.member1 = null;
}
AppCtrl.prorotype.specificMethod = function(){
}
return AppCtrl;
})(CommonCtrl)
app.controller('AppCtrl', AppCtrl);