squash! fix tabs

directive interface definition and tests
This commit is contained in:
Paulo Cesar
2014-08-08 12:24:43 -03:00
parent e6da97bb7d
commit 82447ac010
2 changed files with 27 additions and 24 deletions
+17 -15
View File
@@ -285,15 +285,17 @@ class SampleDirective implements ng.IDirective {
public restrict = 'A';
name = 'doh';
compile(templateElement: any) {
return this.link;
compile(templateElement: ng.IAugmentedJQuery) {
return {
post: this.link
};
}
static instance():ng.IDirective {
return new SampleDirective();
}
link(scope: any) {
link(scope: ng.IScope) {
}
}
@@ -301,7 +303,7 @@ class SampleDirective implements ng.IDirective {
class SampleDirective2 implements ng.IDirective {
public restrict = 'EAC';
compile(templateElement: any) {
compile(templateElement: ng.IAugmentedJQuery) {
return {
pre: this.link
};
@@ -311,7 +313,7 @@ class SampleDirective2 implements ng.IDirective {
return new SampleDirective2();
}
link(scope: any) {
link(scope: ng.IScope) {
}
}
@@ -413,10 +415,10 @@ angular.module('docsTimeDirective', [])
.controller('Controller', ['$scope', function($scope: any) {
$scope.format = 'M/d/yy h:mm:ss a';
}])
.directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any): ng.IDirective {
.directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) {
return {
link: function(scope: any, element: any, attrs: any) {
link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) {
var format: any,
timeoutId: any;
@@ -424,7 +426,7 @@ angular.module('docsTimeDirective', [])
element.text(dateFilter(new Date(), format));
}
scope.$watch(attrs.myCurrentTime, function (value: any) {
scope.$watch(attrs['myCurrentTime'], function (value: any) {
format = value;
updateTime();
});
@@ -463,8 +465,8 @@ angular.module('docsTransclusionExample', [])
transclude: true,
scope: {},
templateUrl: 'my-dialog.html',
link: function (scope: any, element: any) {
scope.name = 'Jeff';
link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) {
scope['name'] = 'Jeff';
}
};
});
@@ -533,10 +535,10 @@ angular.module('docsTabsExample', [])
restrict: 'E',
transclude: true,
scope: {},
controller: function($scope: any) {
var panes: any = $scope.panes = [];
controller: function($scope: ng.IScope) {
var panes: any = $scope['panes'] = [];
$scope.select = function(pane: any) {
$scope['select'] = function(pane: any) {
angular.forEach(panes, function(pane: any) {
pane.selected = false;
});
@@ -545,7 +547,7 @@ angular.module('docsTabsExample', [])
this.addPane = function(pane: any) {
if (panes.length === 0) {
$scope.select(pane);
$scope['select'](pane);
}
panes.push(pane);
};
@@ -561,7 +563,7 @@ angular.module('docsTabsExample', [])
scope: {
title: '@'
},
link: function(scope: any, element: any, attrs: any, tabsCtrl: any) {
link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) {
tabsCtrl.addPane(scope);
},
templateUrl: 'my-pane.html'
+10 -9
View File
@@ -316,6 +316,7 @@ declare module ng {
// see http://docs.angularjs.org/api/ng.$rootScope.Scope
///////////////////////////////////////////////////////////////////////////
interface IScope {
[index: string]: any;
$apply(): any;
$apply(exp: string): any;
$apply(exp: (scope: IScope) => any): any;
@@ -1033,11 +1034,11 @@ declare module ng {
interface IDirectiveLinkFn {
(
scope?: IScope,
instanceElement?: IAugmentedJQuery,
instanceAttributes?: IAttributes,
controller?: any,
transclude?: ITranscludeFunction
scope: IScope,
instanceElement: IAugmentedJQuery,
instanceAttributes: IAttributes,
controller: any,
transclude: ITranscludeFunction
): void;
}
@@ -1048,13 +1049,13 @@ declare module ng {
interface IDirectiveCompileFn {
(
templateElement?: IAugmentedJQuery,
templateAttributes?: IAttributes,
transclude?: ITranscludeFunction
templateElement: IAugmentedJQuery,
templateAttributes: IAttributes,
transclude: ITranscludeFunction
): IDirectivePrePost;
}
interface IDirective{
interface IDirective {
compile?: IDirectiveCompileFn;
controller?: any;
controllerAs?: string;