本文整理汇总了TypeScript中angular.ICompileService类的典型用法代码示例。如果您正苦于以下问题:TypeScript ICompileService类的具体用法?TypeScript ICompileService怎么用?TypeScript ICompileService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ICompileService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe("Meeting Contacts Component", () => {
let component: JQuery, meetingService: MeetingService;
let $controller: IControllerService, $rootScope: IRootScopeService, $compile: ICompileService, $q: IQService;
let $scope: IScope;
beforeEach(() => angular.mock.module(MEETINGS_MODULE));
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$compile = $injector.get("$compile");
$q = $injector.get("$q");
meetingService = $injector.get("MeetingService");
$scope = $rootScope.$new(true);
component = angular.element(`<meeting-contacts></meeting-contacts>`);
$compile(component)($scope);
$scope.$digest();
}));
it("should initialise", () => {
expect(component).toBeDefined();
});
});
示例2: beforeEach
beforeEach(inject(function ($compile: ICompileService, $q: IQService, NgTableParams: ITableParamsConstructor<IPerson>) {
elm = ng1.element(
'<div>' +
'<table ng-table-dynamic="tableParams with cols">' +
'<tr ng-repeat="user in $data">' +
"<td ng-repeat=\"col in $columns\">{{user[col.field]}}</td>" +
'</tr>' +
'</table>' +
'</div>');
scope.tableParams = new NgTableParams({}, {});
scope.cols = [
{
field: 'name',
title: 'Name'
},
{
field: 'age',
title: 'Age'
},
{
field: 'money',
title: 'Money'
}
];
$compile(elm)(scope);
scope.$digest();
}));
示例3:
angular.mock.inject(($rootScope: IRootScopeService, $compile: ICompileService) => {
$element = $compile(`
<div>
<foo bar="bar" ng-if="visible"></foo>
</div>
`)($scope = $rootScope.$new());
});
示例4: it
it('when sorting changes should trigger reload of table', inject(function ($compile: ICompileService) {
var elm = ng1.element(
'<table ng-table="tableParams">' +
'<tr ng-repeat="user in $data"><td title="\'Age\'" sortable="\'age\'">{{user.age}}</td></tr>' +
'</table>');
$compile(elm)(scope);
var params = createNgTableParams<IPerson>();
scope.tableParams = params;
scope.$digest();
(params.settings().getData as jasmine.Spy).calls.reset();
params.sorting()['age'] = 'desc';
scope.$digest();
expect((params.settings().getData as jasmine.Spy).calls.count()).toBe(1);
params.sorting()['age'] = 'asc';
scope.$digest();
expect((params.settings().getData as jasmine.Spy).calls.count()).toBe(2);
// setting the same sort order should not trigger reload
params.sorting({ age: 'asc' });
scope.$digest();
expect((params.settings().getData as jasmine.Spy).calls.count()).toBe(2);
}));
示例5: beforeEach
beforeEach(inject(function ($compile: ICompileService) {
ageFilter = { age: 'text' };
elm = ng1.element(
'<div>' +
'<script type="text/ng-template" id="ng-table/filters/number.html"><input type="number" name="{{name}}"/></script>' +
'<table ng-table="tableParams">' +
'<tr ng-repeat="user in $data">' +
'<td title="\'Name\'" filter="getFilter($column)">{{user.name}}</td>' +
'<td title="\'Age\'" filter="getFilter($column)">{{user.age}}</td>' +
'</tr>' +
'</table>' +
'</div>');
$compile(elm)(scope);
scope.$digest();
scope.getFilter = function (colDef) {
if (colDef.id === 0) {
return { username: 'text' };
} else if (colDef.id === 1) {
return ageFilter;
} else {
return undefined;
}
};
scope.tableParams = createNgTableParams<IPerson>();
scope.$digest();
}));
示例6: describe
describe("Meeting District Component", () => {
let component: JQuery, ctrl: MeetingDistrictCtrl, meetingService: MeetingService;
let $controller: IControllerService, $rootScope: IRootScopeService, $compile: ICompileService, $q: IQService;
let $scope: IScope;
beforeEach(() => angular.mock.module(MEETINGS_MODULE));
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$compile = $injector.get("$compile");
$q = $injector.get("$q");
meetingService = $injector.get("MeetingService");
$scope = $rootScope.$new(true);
spyOn(meetingService, "getDistricts").and.callFake(() => {
const deferred: IDeferred<Array<IDistrict>> = $q.defer();
deferred.resolve(TestDistricts);
return deferred.promise;
});
component = angular.element(`<meeting-district></meeting-district>`);
$compile(component)($scope);
ctrl = component.controller("meetingDistrict");
$scope.$digest();
}));
it("should initialise", () => {
expect(component).toBeDefined();
});
});
示例7: function
function () {
let $scope = $rootScope.$new()
let ganttApi
let ready = false
$scope.api = function (api) {
ganttApi = api
ganttApi.core.on.ready($scope, function () {
ready = true
})
}
$compile('<div gantt api="api"></div>')($scope)
$scope.$digest()
$timeout.flush()
expect(ganttApi).to.be.not.undefined
expect(ready).to.be.ok
ganttApi = undefined
ready = false
$compile('<div gantt api="api"></div>')($scope)
$scope.$digest()
$timeout.flush()
expect(ganttApi).to.be.not.undefined
expect(ready).to.be.ok
}
示例8: function
this.compileDirectiveTemplates = function () {
if (!$element.hasClass('ng-table')) {
$scope.templates = {
header: ($attrs.templateHeader ? $attrs.templateHeader : 'ng-table/header.html'),
pagination: ($attrs.templatePagination ? $attrs.templatePagination : 'ng-table/pager.html')
};
$element.addClass('ng-table');
var headerTemplate: IAugmentedJQuery = null;
// $element.find('> thead').length === 0 doesn't work on jqlite
var theadFound = false;
ng1.forEach($element.children(), function (e) {
if (e.tagName === 'THEAD') {
theadFound = true;
}
});
if (!theadFound) {
headerTemplate = ng1.element('<thead ng-include="templates.header"></thead>', $document);
$element.prepend(headerTemplate);
}
var paginationTemplate = ng1.element(
'<div ng-table-pagination="params" template-url="templates.pagination"></div>',
$document
);
$element.after(paginationTemplate);
if (headerTemplate) {
$compile(headerTemplate)($scope);
}
$compile(paginationTemplate)($scope);
}
};
示例9: beforeEach
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$compile = $injector.get("$compile");
$q = $injector.get("$q");
$scope = $rootScope.$new(true);
downloadsService = $injector.get("DownloadsService");
spyOn(downloadsService, "getDownloads").and.callFake(() => {
const deferred: IDeferred<Array<IDownload>> = $q.defer();
deferred.resolve(TestDownloads);
return deferred.promise;
});
spyOn(downloadsService, "getCategories").and.callFake(() => {
const deferred: IDeferred<Array<ICategory>> = $q.defer();
deferred.resolve(TestCategories);
return deferred.promise;
});
component = angular.element(`<downloads></downloads>`);
$compile(component)($scope);
ctrl = component.controller("downloads");
$scope.$digest();
}));
示例10: function
function () {
let $scope = $rootScope.$new()
$scope.data = angular.copy(mockData)
let ganttElement = $compile('<div gantt data="data"><gantt-tree></gantt-tree></div>')($scope)
$scope.$digest()
$timeout.flush()
// Set the data in tree view ordering
let orderedData = $scope.data.slice()
let indices = {}
angular.forEach($scope.data, function (rowModel, i) {
if (rowModel.name) {
indices[rowModel.name] = i
}
})
/*jshint sub:true */
let configRow = orderedData[indices['Config']]
let setupRow = orderedData[indices['Setup']]
let serverRow = orderedData[indices['Server']]
orderedData[indices['Setup']] = serverRow
orderedData[indices['Config']] = setupRow
orderedData[indices['Server']] = configRow
/*jshint sub:false */
checkLabels(orderedData, ganttElement)
}