Is there a way to access the controller's scope properties using my custom TypeScript
directive?
For example, in this snippet below, I am trying to retrieve and log scope.message
:
/// <reference path="typings/angularjs/angular.d.ts" />
//module
module app {
var mainModule = angular.module('mainModule', []);
}
//controller
module app.testCtrl {
interface ITest {
message: string;
}
class TestCtrl implements ITest {
message: string = 'initial value'; // This is the specific value I am aiming to access from within my directive
}
angular.module('mainModule').controller('testCtrl', TestCtrl);
}
//directive
module app.directives {
export class MyDirective implements ng.IDirective {
restrict = 'A';
static instance(): ng.IDirective {
return new MyDirective;
}
link(scope: ng.IScope) {
//How do I navigate to the scope properties?
//console.log(scope.???);
}
}
angular.module('mainModule').directive('myDirective', MyDirective.instance);
}
P.S - I am utilizing the "controller as" syntax on the view; does that affect anything?