我一直在努力寻找一种方法来动态改变材料设计扩展面板标题的背景颜色,具体取决于面板是否展开.
当面板关闭时,我希望背景颜色为白色,但是当它被展开时,我想将该颜色更改为其他颜色.我没有看到我可以根据这个改变做出的事情,也许我错过了一些东西.我是棱角分明的新人,并且认为我只能将它从[扩展]的设置中解脱出来,但事实并非如此.
mat-accordion
mat-expansion-panel
mat-expansion-panel-header
mat-expanded{
font-size: 1.25em;
background-color: white;
background: white;
color: #00838f;
font-weight: 500;
}
mat-accordion
mat-expansion-panel
mat-expansion-panel-header {
font-size: 1.25em;
background-color: white;
background: white;
color: #00838f;
font-weight: 500;
}
mat-accordion
mat-expansion-panel
.mat-expansion-panel-body {
background-color: white;
padding-top: 5px;
}
.mat-expansion-indicator::after {
color: #00838f;
}Run Code Online (Sandbox Code Playgroud)
<mat-accordion multi="true">
<mat-expansion-panel [expanded]="selectedBenefitCategories.indexOf(cat)!=-1" [hidden]="selectedBenefitCategories.indexOf(cat)===-1">
<mat-expansion-panel-header>
<i class="search-category-icon far fa-star"></i> {{cat}}
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
some content
</ng-template>
</mat-expansion-panel>
</mat-accordion>Run Code Online (Sandbox Code Playgroud)
在旧的角度cli中有一个键叫做defaults:
"defaults": {
"schematics": {
"collection": "@nrwl/schematics",
"postGenerate": "npm run format",
"newProject": [
"app",
"lib"
]
},
"styleExt": "scss",
"component": {
"changeDetection": "OnPush"
}
}
Run Code Online (Sandbox Code Playgroud)
这家酒店不再存在.如何在角度cli 6+中添加component/changeDetection?还有我可以添加的组件属性列表吗?
我对angular 6非常新,我在HTML中创建了标签,我需要将其转换为角度6并使其动态化.下面是我的HTML代码 -
<ul class="nav nav-tabs side_nav" role="tablist">
<li role="presentation" class="dashboard_li active">
<a href="#one" class="coin_name" aria-controls="one" role="tab" data-toggle="tab"></a>
</li>
<li role="presentation" class="dashboard_li">
<a href="#two" class="coin_name" aria-controls="two" role="tab" data-toggle="tab"></a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="one"></div>
<div role="tabpanel" class="tab-pane active" id="two"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
我已将其转换为角度6,下面是我的角度代码 -
<ul class="nav nav-tabs side_nav" role="tablist">
<li *ngFor="let wallet of coinwallet; let first = first;" [ngClass]="{firstItem: first}" role="presentation" class="accounts_li" [class.active]="selectedwallet===wallet">
<a (click)="selectedwallet = coinwallet" aria-controls="one" role="tab" data-toggle="tab"></a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="one"></div> …Run Code Online (Sandbox Code Playgroud) 我是ngrx状态管理的新手,我正在使用@ ngrx / store和6.0.1的效果,假设我想保存一个新的成员联系人,所以我已经做好了以下准备:
成员效应
@Effect()
memberContactCreate$ = this.actions$.pipe(
ofType(MemberActions.MemberActionTypes.MemberContactCreate),
switchMap((action: MemberActions.MemberContactCreate) => {
return this.memberService.createMemberDetail(action.payload);
}),
map(
(response) => {
console.log('MemberContactCreate$ MemberContactCreate response: ', response);
if (!response.didError) {
return new MemberActions.MemberContactCreateSuccess(response.model as MemberDetailResponse);
} else {
return new MemberActions.MemberContactCreateFailure(response.errorMessage);
}
},
),
);
Run Code Online (Sandbox Code Playgroud)在我的成员联系组件提交中,我将调度创建动作
this.store.dispatch(new fromAction.MemberContactCreate(<MemberDetailRequest>this.memberDetailForm.value));
但是,我想显示一个敬酒或通知,如果我的成员从服务器成功创建(在我的@Effect方法中定义),则返回新动作“ MemberActions.MemberContactCreateSuccess ”,但是我如何才能在我的组件中捕获此动作呢?马上被发射?我试图做下面的事情并将其放在我的ngOnInit中,并认为它可以像订阅一样使用,但事实并非如此,实际上它每次都像页面加载一样触发,甚至我没有调度我的memberContactCreate操作...
this.store.select(fromSelector.getMemberCreateSuccess)
.subscribe((stateSelector) => {
console.log('getMemberCreateSuccess: ', stateSelector);
setTimeout(() => {
this.toastr('Hooray',
'New contact has been created successfully!');
}, …Run Code Online (Sandbox Code Playgroud) 我试图以角度广告一些自定义类型定义文件,但面临一些错误.
在app文件夹中我有外部文件夹,其中我有external.d.ts文件和下面的代码
declare function format(input: string, ...args): string;
Run Code Online (Sandbox Code Playgroud)
在tsconfig.json我尝试添加"文件":["/ app/external/external.d.ts"]
但它不起作用.
有人可以给我一些关于添加自定义打字文件到角6的想法.
我已经nav-bar通过此命令使用cli 创建了
ng g @angular/material:material-nav --name=version-nav
Run Code Online (Sandbox Code Playgroud)
并在我的组件中导入为
<app-version-nav></app-version-nav>
Run Code Online (Sandbox Code Playgroud)
并得到这个错误
任何有益的建议将不胜感激
我只是ngx-gallery在尝试使用Google图片中的一些网址进行项目,但是每次在控制台中遇到以下错误时:
ERROR TypeError: Cannot read property 'replace' of undefined
at NgxGalleryHelperService.push../node_modules/ngx-gallery/bundles/ngx-gallery.umd.js.NgxGalleryHelperService.validateUrl (ngx-gallery.umd.js:121)
at NgxGalleryHelperService.push../node_modules/ngx-gallery/bundles/ngx-gallery.umd.js.NgxGalleryHelperService.getBackgroundUrl (ngx-gallery.umd.js:133)
at NgxGalleryImageComponent.push../node_modules/ngx-gallery/bundles/ngx-gallery.umd.js.NgxGalleryImageComponent.getSafeUrl (ngx-gallery.umd.js:367)
at Object.eval [as updateRenderer] (NgxGalleryImageComponent.html:3)
at Object.debugUpdateRenderer [as updateRenderer] (core.js:10872)
at checkAndUpdateView (core.js:10248)
at callViewAction (core.js:10484)
at execEmbeddedViewsAction (core.js:10447)
at checkAndUpdateView (core.js:10244)
at callViewAction (core.js:10484)
这是我的component.ts
export class FefileComponent implements OnInit {
galleryOptions: NgxGalleryOptions[];
galleryImages: NgxGalleryImage[];
ngOnInit(): void {
this.galleryOptions = [
{
'imageArrows': true,
'imageSwipe': false,
'thumbnailsArrows': true,
'thumbnailsSwipe': false,
'previewSwipe': true,
'thumbnailsMargin': 0,
'thumbnailMargin': 0,
'thumbnailsColumns': 6,
'width': …Run Code Online (Sandbox Code Playgroud) 我将Angular 6.1.9及其路由器模块一起使用。对于我来说,路由/显示命名的插座内容似乎是不可能的。
调用<a [routerLink]="['', { outlets: { editArea: ['addRootPartner'] } }]">foo</a>时崩溃:
NavigationError(id:2,url:'/ overview / work / allPartners(editArea:addRootPartner)',错误:错误:无法匹配任何路由。URL段:'addRootPartner')
我的应用程序结构为:
app.module
app-routing.module
workspace.module
workspace-routing.module
Run Code Online (Sandbox Code Playgroud)
应用路由:
const rootAppRoutes: Routes = [
{ path: '', redirectTo: 'overview', pathMatch: 'full' },
{ path: 'overview', loadChildren: './overview/workplace/workplace.module#WorkplaceModule' },
{ path: '**', component: PageNotFoundComponent }
];
Run Code Online (Sandbox Code Playgroud)
重定向到overview加载workplace模块的。
工作场所路由:
const workplaceRoutes: Routes = [
{ path: '', redirectTo: 'work', pathMatch: 'full'},
{ path: 'work', component: WorkplaceComponent, children: [ …Run Code Online (Sandbox Code Playgroud) 我有一个标头组件,该组件进行调用以获取用户令牌并存储用户的数据。然后,我有一个不同的组件(管理组件),它不是标头的子代,它依赖于用户数据来获取其他数据。我遇到的问题是管理组件在标头组件完成对用户的调用之前初始化,因此破坏了我的管理组件。换句话说,由于标题尚未设置活动公司,因此代码执行中断。有没有办法确保这些在Angular 6中同步加载,这样我就可以避免此问题?
header.component.ts
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../../services/auth.service';
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.css']
})
export class HeaderComponent implements OnInit {
user: any;
activeCompany: any;
constructor(private authService: AuthService) { }
ngOnInit() {
this.authService.getToken().then((user) => {
this.user = user;
this.user.Companies = JSON.parse(this.user.Companies.split('"').join('"'));
this.authService.getActiveCompany$().subscribe((company: any) => {
if(!company) {
let company = this.user.Companies[0]
this.authService.setActiveCompany$(JSON.stringify(company));
}
this.activeCompany = company;
});
});
}
setActiveCompany(company) {
this.authService.setActiveCompany$(company)
}
}
Run Code Online (Sandbox Code Playgroud)
admin.component.ts
import { Component, OnInit } from …Run Code Online (Sandbox Code Playgroud) angular6 ×10
angular ×8
angular5 ×2
html ×2
angular-cli ×1
css ×1
ngrx ×1
ngrx-effects ×1
ngrx-store ×1
router ×1
scroll ×1
tabs ×1
typescript ×1