标签: angular6

生成新的角度组件时无法获得.scss而不是.css

我想通过angular cli创建新组件时生成.scss文件,但我得到.css文件.尝试添加默认值

"defaults": {   
     "styleExt": "scss", 
} 
Run Code Online (Sandbox Code Playgroud)

在angular.json但它没有用.我正在研究最新版本,即Angular 6.任何人都知道如何获得这个?

sass angular angular6

4
推荐指数
1
解决办法
1976
查看次数

无法将Angular从版本6降级到5

最近更新的稳定版角度已经发布.我已成功从第5版迁移到第6版.

但由于某种原因,我想回滚到版本5.我尝试了以下命令:

npm uninstall -g @angular/cli
Run Code Online (Sandbox Code Playgroud)

它卸载了最新版本的angular-6.

npm cache clean --force
Run Code Online (Sandbox Code Playgroud)

然后安装

npm install -g @angular/cli@1.7.4
Run Code Online (Sandbox Code Playgroud)

但它给出了这个错误 在此输入图像描述

节点版本:8.10.0

npm版本:6.0.0

rollback downgrade angular angular5 angular6

4
推荐指数
2
解决办法
2万
查看次数

Angular 6的angular-material-multilevel菜单?

我试图实现多层次的sidenav,发现这符合我的要求:

角材料多级菜单

演示 -注意手风琴类型

不幸的是,这是为AngularJS(1.0?)创建的,在Angular 6中似乎不起作用。

我的问题是:

  1. Angular 6是否还有其他任何多层sidenav组件?注意在Google上找到任何类似的作品。
  2. 是否可以将此Angular 1.0菜单“升级”到Angular 6?怎么样?
  3. 是否有任何简单的说明或课程来构建您自己的多层次侧面导航?有很多关于一级的说明,但是我发现没有多层的说明。

sidenav angular6

4
推荐指数
1
解决办法
2万
查看次数

如何从浏览器控制台调用angular 6函数?

我想从浏览器控制台调用组件内部的函数。我想是这样 ,但相当于角6。

先感谢您

angular6

4
推荐指数
1
解决办法
1718
查看次数

Http.post不工作​​角6

我使用这个工具根据我的模型生成了我的实体组件和服务.

一切正常,但我在尝试在API中记录用户时遇到了问题(功能正常).

http.post()方法未被触发.我对角度很新,也无法弄清楚我做错了什么.

任何帮助都会很棒!

这是我的UserService的登录方法(该方法被正确调用,它只是http.post()不起作用):

/**
 * Log a user by its credentials.
 */
login(username : string, password : string) : Observable<NmUser> {
    let body = JSON.stringify({
        'username': username,
        'password': password
    });
    console.log(body);
    return this.http.post(this.userUrl + 'login', body, httpOptions)
        .pipe(
            map(response => new NmUser(response)),
            catchError(this.handleError)
        );
} // sample method from angular doc
private handleError (error: HttpErrorResponse) {
    // TODO: seems we cannot use messageService from here...
    let errMsg = (error.message) ? error.message : 'Server error';
    console.error(errMsg);
    if …
Run Code Online (Sandbox Code Playgroud)

http angular angular-httpclient angular6

4
推荐指数
1
解决办法
9549
查看次数

Angular中儿童父母沟通的最佳做法

我想在Angular变得更好,我想知道儿童与父母之间的交流的最佳做法。我当前要使用的应用程序是在Angular 6上运行的。我知道我可以使用@ ViewChild,@ Output或创建服务在父级组件之间进行通信。还有其他沟通方式吗?如果不是,那三者中哪一个更好,为什么?

这是一个简单的例子:

子HTML

<button (click)="onLinkedClicked();">Click me</button>
Run Code Online (Sandbox Code Playgroud)

儿童TS

import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
.
.
.
export class showcaseMenuComponent implements OnInit {
    @Output() public linkedClicked = new EventEmitter<String>();

    constructor() {}

    onLinkedClicked() {
        console.log('on click child');
        this.linkedClicked.emit('collapsed');
    }
}
Run Code Online (Sandbox Code Playgroud)

父HTML

<showcase-menu #topNavMenu 
               [showBranding]="false"
               [showSearch]= "false"  
               (linkedClicked)="linkToggler($event)">. 
</showcase-menu>
Run Code Online (Sandbox Code Playgroud)

家长TS

.
.
.
 navMenuState: string;
.
.
.
  linkToggler($event) {
    console.log("partent");
    this.navMenuState = $event;
  }
Run Code Online (Sandbox Code Playgroud)

viewchild angular angular6

4
推荐指数
1
解决办法
5008
查看次数

如何让Google Chrome在Angular 4应用程序中全屏显示?

我正在开发一个应用程序,我希望实现这样的事情:如果用户从一个组件离开并进入其他组件,那么在其他组件的ngOnInit方法中,chrome浏览器应该全屏显示与按Fn + F11键时相同的全屏.

任何帮助或参考表示赞赏.

google-chrome typescript angular angular6

4
推荐指数
3
解决办法
1万
查看次数

Ionic 4 cordova cordova-plugin-facebook4:'FacebookOriginal'类型中缺少属性'provide'

我遇到了Ionic 4,Cordova,Angular6应用程序的问题.在cordova-plugin-facebook4安装并添加到app.module.ts文件之后,TS编译器会产生以下错误:

[ng] ? ?wdm?: Compiled successfully.
[ng] ERROR in src/app/app.module.ts(13,11): error TS2345: Argument of type '{ declarations: (typeof AppComponent)[]; entryComponents: undefined[]; imports: (ModuleWithProvid...' is not assignable to parameter of type 'NgModule'.
[ng]   Types of property 'providers' are incompatible.
[ng]     Type '(typeof SplashScreen | FacebookOriginal | { provide: typeof RouteReuseStrategy; useClass: typeof ...' is not assignable to type 'Provider[]'.
[ng]       Type 'typeof SplashScreen | FacebookOriginal | { provide: typeof RouteReuseStrategy; useClass: typeof I...' is not assignable to type …

cordova ionic4 angular6

4
推荐指数
1
解决办法
4524
查看次数

有效模板上的"意外结束标记"错误非常不直观

这是我学习角度的第一天,我遇到了一条非常不直观的错误信息,其中说:

未捕获错误:模板解析错误:意外结束标记"p".当标签已被另一个标签关闭时,可能会发生这种情况.欲了解更多信息请参阅 https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags("数字{{I + 1}} {{} phoneNumber的} [错误 - >]

"):ng:///AppModule/AddressCardComponent.html@5:0

在有效的html模板上抛出错误,如下所示:

<p>Phones:</p>
<p *ngFor="let phoneNumber of user.phone; index as i">
  <h3>
      Number {{ i + 1 }}: {{ phoneNumber }}
  </h3>
</p>
Run Code Online (Sandbox Code Playgroud)

在组件本身它看起来像这样:

@Component({
  selector: 'app-address-card',
  templateUrl: './address-card.component.html',
  styleUrls: ['./address-card.component.scss']
})
export class AddressCardComponent implements OnInit {

  user: any;

  constructor() {
    this.user = {
      name: 'Foo Bar',
      title: 'Software Developer',
      address: '1234 Main St., State, City 610010',
      phone: [
        '123-123-1234',
        '456-546-4574'
      ]
    }
  }

  ngOnInit() {
  }

} …
Run Code Online (Sandbox Code Playgroud)

html javascript angular angular6 angular7

4
推荐指数
1
解决办法
1594
查看次数

Angular 6库-无法解析条目

构建angular库项目时出现以下错误。

Building Angular Package
Building entry point '@abc/lib'
Compiling TypeScript sources through ngc
Bundling to FESM2015

BUILD ERROR
Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
    at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
    at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17

Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
Error: Could not resolve entry (C:\Dev\abc\build\dist-npm\esm2015\abc-lib.js)
    at error (C:\Dev\abc\node_modules\rollup\dist\rollup.js:3460:30)
    at C:\Dev\AppBuilder\node_modules\rollup\dist\rollup.js:21474:17
Run Code Online (Sandbox Code Playgroud)

当我module在public_api.ts文件中添加新内容时,我只会收到此错误

export * from './lib/designer.service';
export * from './lib/designer.component';
export * from './lib/designer.module';
export * from './lib/core/app-core.module'; // new module
Run Code Online (Sandbox Code Playgroud)

我正在使用以下命令来构建模块

ng建立库

知道为什么我会收到此错误吗?

angular angular-library angular6

4
推荐指数
1
解决办法
3493
查看次数