本文整理匯總了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