How Can I Access A Scope Function In A Parent Controller From A Child Controller When Using Typescript?
I have a parent controller AppController for a DIV on my page and a child controller AdminHomeController that's in an area of the page inside that. Here is what I have defined so f
Solution 1:
Here is the complete code:
/// <reference path="angular.d.ts" />var app = angular.module('app', []);
interfaceAppControllerScopeextendsng.IScope{
app: AppController;
}
app.controller('appController', AppController);
classAppController{
static$inject = ['$scope'];
constructor(public$scope: AppControllerScope) {
$scope.app = this;
}
doTask = () => {
var x = 99;
}
}
interfaceAdminHomeControllerScopeextendsAppControllerScope{
home: AdminHomeController;
}
classAdminHomeController{
public app: AppController;
static$inject = ['$scope'];
constructor(public$scope: AdminHomeControllerScope) { // << What should my interface look like?$scope.home = this;
$scope.app.doTask();
// For easier access if you want it
this.app = $scope.app;
}
}
There were a few code formatting (compile errors) in your code sample. I fixed those as well ^
Post a Comment for "How Can I Access A Scope Function In A Parent Controller From A Child Controller When Using Typescript?"