在混乱开始之前,这个问题是关于Code,新的轻量级Visual Studio编辑器.你可以从这里得到它:https://code.visualstudio.com/
我有一个带有CSS的文本文件(.txt),并希望获得语法高亮显示.您可以使用ctrl + shift + p打开命令调色板.但是你不能在Sublime中设置语法.
有没有其他方法可以从我的文本文件中获取CSS着色?
我试图通过枚举访问地图的值,并为其中的所有字符串创建一个翻译就绪的应用程序.两个问题都重叠,我必须决定使用枚举还是只使用JSON格式的对象.
那么枚举和对象之间的区别和用途到底是什么?
例如:
const enum FieldNames {
FirstField: "Field One",
SecondField: "Field Two"
};
someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;Run Code Online (Sandbox Code Playgroud)
const FieldNames = {
FirstField: "Field One",
SecondField: "Field Two"
};
someFieldArray[FieldNames.FirstField].label = FieldNames.FirstField;
someFieldArray[FieldNames.SecondField].label = FieldNames.SecondField;Run Code Online (Sandbox Code Playgroud)
我真的没有从简单对象中选择枚举的好处.在我看来,一个对象有更多的好处,没有任何缺点.
我正在尝试在我的自定义 Angular Material 主题中将自定义调色板中的颜色用于其他一些组件。
例如,带有 mat-toolbar 的 div 和带有边距的图标,应填充主要背景色。
关于主题的 Angular Material 指南说:
不应将主题文件导入其他 SCSS 文件。这将导致重复的样式写入您的 CSS 输出。
但是在组件主题的指南中,它说明了以下内容:
您可以使用@angular/material/theming 中的主题函数和材料调色板变量。您可以使用 mat-color 函数从调色板中提取特定颜色。例如:
// Import theming functions
@import '~@angular/material/theming';
// Import your custom theme
@import 'src/unicorn-app-theme.scss';
// Use mat-color to extract individual colors from a palette as necessary.
// The hue can be one of the standard values (500, A400, etc.), one of the three preconfigured
// hues (default, lighter, darker), or any of the aforementioned prefixed with "-contrast".
// …Run Code Online (Sandbox Code Playgroud) 我想将PageNotFoundComponent我的ui-components库中的内容导入到我的应用程序的路由器中。
当我将 导入UiComponentsModule到 myAppModule并使用模板中的组件时,一切正常,但以 es6 表示法导入组件失败。
/libs/ui-components/src/lib/ui-components.module.ts
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ContactCardComponent } from './contact-card/contact-card.component';
import { NotFoundComponent } from './not-found/not-found.component';
import { WhiteLabelFooterComponent } from './white-label-footer/white-label-footer.component';
import { WhiteLabelHeaderComponent } from './white-label-header/white-label-header.component';
@NgModule({
declarations: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
exports: [
ContactCardComponent,
WhiteLabelFooterComponent,
WhiteLabelHeaderComponent,
NotFoundComponent
],
imports: [CommonModule],
})
export class UiComponentsModule {}
Run Code Online (Sandbox Code Playgroud)
/apps/myApp/src/app/app-routing.module.ts
import { NgModule } from '@angular/core'; …Run Code Online (Sandbox Code Playgroud) 我已经在LoadingComponent我的应用程序的根目录中创建了一个小的component()并且(显然)在我的应用程序中声明了它AppModule.我的应用程序加载时会使用此组件,并应显示一些奇特的加载动画.
现在我想在保存一些东西时在子模块中使用它.但是当我想在另一个模块中使用这个组件时,我总是会遇到错误.
我在AppModule中导出了LoadingComponent:
import { ButtonsModule } from './buttons/buttons.module';
import { FormsModule } from '@angular/forms';
import { StatusLightsDisplayComponent } from './status-lights-display/status-lights-display.component';
import { StatusLightsContainerComponent } from './status-lights-container/status-lights-container.component';
import { HttpModule } from '@angular/http';
import { ReportsService } from './services/reports.service';
import { BrowserModule } from '@angular/platform-browser';
import { forwardRef, NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { GeneralInformationComponent } from './general-information/general-information.component';
import { TextfieldsComponent } from './textfields/textfields.component';
import { LoadingComponent } from './loading/loading.component'; …Run Code Online (Sandbox Code Playgroud)对 @Angular-devkit/build-Angular 包进行小幅更新后,构建脚本不再工作。当我开始构建时ng build app --base-href /app/ --output-path ./dist/app/de/ --deployUrl /en/app/ --configuration=dev出现未处理的异常:
An unhandled exception occurred: File C:\Users\<User>\Projects\<project>\angular\node_modules\@angular\cli\commands\build-long.md was not found while constructing the subcommand build.
之后我升级到最新版本 9 并重新安装完整的软件包,结果相同。我也更新了@angular/cli,但@angular/compiler-cli没有任何改变。我删除了该node_modules文件夹并重新安装了所有内容。问题依然存在...
然后我降级@angular-devkit/build-angular到版本0.802.2.(低于升级前我们使用的版本)并出现完全相同的问题。
我查看了压缩包,没有任何build-long.md文件。为什么会出现这个问题?有人可以帮忙吗?
例如,我的组件中有私有类成员
private querySubscription: Subscription;。
在我的ngOnDestroy()订阅中取消订阅:
ngOnDestroy(): void {
this.querySubscription.unsubscribe();
this.userSettingsSubscription.unsubscribe();
}
如何在茉莉花单元测试中测试我是否确实正确取消订阅?我可以以编程方式调用,ngOnDestory()因为它是公共的,但我无法测试我的私有类成员。
我收到以下错误:
compiler.js:486未捕获错误:模板解析错误:无法绑定到'dataSource',因为它不是'table'的已知属性.
我正在将表插入自定义材料模态组件,该组件应显示历史条目列表.
HistoryComponent:
import { Component, OnInit, ViewChild } from "@angular/core";
import { MatTableDataSource, MatSort } from "@angular/material";
@Component({
selector: "app-history",
templateUrl: "./history.component.html",
styleUrls: ["./history.component.scss"],
})
export class HistoryComponent implements OnInit {
displayedColumns = ["position", "name", "weight", "symbol"];
dataSource = ELEMENT_DATA;
constructor() { }
ngOnInit() {
}
}
export interface Element {
name: string;
position: number;
weight: number;
symbol: string;
}
const ELEMENT_DATA: Element[] = [
{position: 1, name: "Hydrogen", weight: 1.0079, symbol: "H"},
{position: 2, name: "Helium", weight: …Run Code Online (Sandbox Code Playgroud)javascript typescript material-design angular-material angular
angular ×6
typescript ×3
javascript ×2
angular-cli ×1
editor ×1
enums ×1
jasmine ×1
nrwl ×1
nrwl-nx ×1
object ×1
observable ×1
sass ×1
unit-testing ×1