本文整理汇总了TypeScript中@angular/platform-browser.By.directive方法的典型用法代码示例。如果您正苦于以下问题:TypeScript By.directive方法的具体用法?TypeScript By.directive怎么用?TypeScript By.directive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular/platform-browser.By
的用法示例。
在下文中一共展示了By.directive方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should set the title to the navbar', () => {
const component = fixture.debugElement.query(By.directive(NavbarComponent)).componentInstance;
expect(component.title).toEqual(app.title);
});
示例2: getEmbeddedPlunkerComponent
function getEmbeddedPlunkerComponent() {
const compDe = liveExampleDe.query(By.directive(EmbeddedPlunkerComponent));
return compDe && compDe.componentInstance as EmbeddedPlunkerComponent;
}
示例3: expect
.then((fixture: ComponentFixture<any>) => {
let query = fixture.debugElement.query(By.directive(SyncComponent));
expect(query).toBeTruthy();
expect(query.componentInstance).toBeTruthy();
});
示例4: it
it('has no mail header component', () => {
let mailHeader = fixture.debugElement.query(By.directive(MailHeaderComponent));
expect(!!mailHeader).toBeFalsy();
});
示例5: it
it('should render copyable directive', () => {
const copyable = fixture.debugElement.query(By.directive(CopyableComponent));
const copyableInstance = copyable.injector.get(CopyableComponent) as CopyableComponent;
expect(copyableInstance.content).toEqual('a_value');
});
示例6: beforeEach
beforeEach(() => {
directive = fixture.debugElement
.query(By.directive(DataTableColumnDirective))
.injector.get(DataTableColumnDirective);
});
示例7: it
it('should apply CSS class to component', () => {
const compiled = fixture.debugElement.query(By.directive(LoadingComponent)).nativeElement;
expect(compiled.className).toBe('loading');
});
示例8:
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {DebugElement} from '@angular/core';
import {By} from '@angular/platform-browser';
var debugElement: DebugElement;
class MyDirective {}
// #docregion by_all
debugElement.query(By.all());
// #enddocregion
// #docregion by_css
debugElement.query(By.css('[attribute]'));
// #enddocregion
// #docregion by_directive
debugElement.query(By.directive(MyDirective));
// #enddocregion