标签: angular-cli

角度cli钩

我正在寻找修改构建函数输出的方法

ng build --prod
Run Code Online (Sandbox Code Playgroud)

想在index.html的head部分添加一些bootstrap css文件,更改名称index.html => index.php等.

怎么做 ?

hook templates build angular-cli

7
推荐指数
1
解决办法
509
查看次数

在Angular2 RC7和angular-cli webpack中加载延迟

我已经创建了一个新的应用程序,ng new但是当我尝试使用延迟加载配置模块加载时,我不断收到错误,找不到该模块.

EXCEPTION: Uncaught (in promise): Error: Cannot find module 'app/home/home.module'
Run Code Online (Sandbox Code Playgroud)

的package.json

"dependencies": {
    "@angular/common": "2.0.0-rc.7",
    "@angular/compiler": "2.0.0-rc.7",
    "@angular/core": "2.0.0-rc.7",
    "@angular/forms": "2.0.0-rc.7",
    "@angular/http": "2.0.0-rc.7",
    "@angular/platform-browser": "2.0.0-rc.7",
    "@angular/platform-browser-dynamic": "2.0.0-rc.7",
    "@angular/router": "3.0.0-rc.3",
    "core-js": "^2.4.1",
    "rxjs": "5.0.0-beta.12",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.6.21"
  },
  "devDependencies": {
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.11-webpack.9-4",
    "codelyzer": "~0.0.26",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.5",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.2"
  }
Run Code Online (Sandbox Code Playgroud)
  • angular2 RC7
  • angular-cli:1.0.0-beta.11-webpack.9-4
  • 节点:6.5.0
  • os:win32 x64

app.routing.ts:

import …
Run Code Online (Sandbox Code Playgroud)

typescript webpack angular2-routing angular-cli angular

7
推荐指数
1
解决办法
4241
查看次数

Angular 2 Lazy在具有角度路由器的NPM模块中加载NgModule

我一直懒得在路线上加载模块,例如

export const HomeRoute: Route = {
  path: '',
  component: HomeComponent,
  canActivate: [AuthGuard],
  children: [
    {path: 'dashboard', loadChildren: 'app/+dashboard/db.module#DashboardModule'}
  ]
};
Run Code Online (Sandbox Code Playgroud)

我想将我的"页面"放入NPM模块中.我应该在loadChildren属性中使用node_module的路由是什么?我使用的是angular-cli 1.0.0-beta.16

我试过了

{path: 'lazy', loadChildren: '../node_modules/hello-world/components#HelloWorld' }
Run Code Online (Sandbox Code Playgroud)

也

{path: 'lazy', loadChildren: 'hello-world/components#HelloWorld' }
Run Code Online (Sandbox Code Playgroud)

导出的类是: -

import {Component} from '@angular/core';

@Component({
    selector: 'hello-world',
    styles: [`
       h1 {
            color: blue;
        }
    `],
    template: `<div>
                  <h1 (click)="onClick()">{{message}}</h1>
               </div>`
})
export class HelloWorld {

    message = "Click Me ...";

    onClick() {
        this.message = "Hello World!";
        console.log(this.message);

    }
}
Run Code Online (Sandbox Code Playgroud)

还有什么我应该尝试的吗?

angular2-routing angular-cli angular

7
推荐指数
1
解决办法
1195
查看次数

如何将Angular 2(angular-cli)应用程序集成到Sails.js中

我需要将angular-cli生成的应用程序集成到Sails.js中.我来自php背景,所以我对这两个框架都不熟悉.

  1. 如何将它们设置为一个?
  2. 我如何运行ng serve和/或sails lift?
  3. 如何管理Angular路线与Sails路线?

谢谢.

sails.js angular-cli angular

7
推荐指数
1
解决办法
2891
查看次数

将OneSignal与Angular集成

我正在尝试将OneSignal集成到我的Angular 2应用程序中以接收推送通知.首先,我使用普通的旧HTML做了一个HelloWorld应用程序,它运行得很漂亮.所以我试着将它包含在我的Angular应用程序中,但用户没有被创建/注册,因此没有订阅接收任何通知.

代码摘录:

的index.html

<html>

<head>
  <meta charset="utf-8">
  <title>My Angular App</title>
  <base href="/">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <head>
    <link rel="manifest" href="/manifest.json">
  <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
  <script>
    var OneSignal = window.OneSignal || [];
    console.log("Init OneSignal");
    OneSignal.push(["init", {
      appId: "xxx-xxx-xxx-xxx-xxx",
      autoRegister: false,
      allowLocalhostAsSecureOrigin: true,
      notifyButton: {
        enable: true
      }
    }]);
    console.log('OneSignal Initialized');
    OneSignal.push(function () {
      console.log('Registered For Push');
      OneSignal.getUserId().then(function (userId) {
      console.log("User ID is", userId);
      });
    });
  </script>
  </head>
</head>

<body>
  <app-root>
    <div class="wrap">
      <div class="loading outer">
        <div class="loading …
Run Code Online (Sandbox Code Playgroud)

typescript onesignal angular-cli angular

7
推荐指数
1
解决办法
5903
查看次数

Bootstrap Navbar无法正常工作:AngularCLI

我将bootstrap包含在我的angularcli项目中,但是当我尝试包含导航栏时,没有任何元素正常工作.我正在使用网站上的标准boostrap导航栏示例,但它看起来很奇怪:

在此输入图像描述

我的项目导致导航栏无法正确加载有什么问题?

navbar.component.html

在此输入图像描述

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
  <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="#">Navbar</a>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#">Disabled</a>
      </li>
    </ul>
    <form class="form-inline my-2 my-lg-0">
      <input class="form-control mr-sm-2" type="text" placeholder="Search">
      <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
    </form>
  </div>
</nav>
Run Code Online (Sandbox Code Playgroud)

.angular-cli.json

"styles": [
        "../node_modules/bootstrap/dist/css/bootstrap.min.css",
        "styles.css"
      ],
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap angular-cli angular

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

设置Angular Universal App进行开发

我已经使用Angular-CLI创建了一个项目。(使用命令:)ng new my-angular-universal。然后,我仔细地遵循了https://github.com/angular/angular-cli/wiki/stories-universal-rendering的所有说明

它可以构建--prod并正常工作。但是没有关于如何设置--dev构建并将其与--watchflag一起使用的说明。

我尝试--prod从npm“ scripts”中删除标志,它甚至不在开发模式下运行。它构建良好,但是当我在浏览器中打开它时,这就是我所看到的(直接打印为响应):

 TypeError: Cannot read property 'moduleType' of undefined
    at C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:7069:134
    at ZoneDelegate.invoke (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:105076:26)
    at Object.onInvoke (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:6328:33)
    at ZoneDelegate.invoke (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:105075:32)
    at Zone.run (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:104826:43)
    at NgZone.run (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:6145:69)
    at PlatformRef.bootstrapModuleFactory (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:7068:23)
    at Object.renderModuleFactory (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:52132:39)
    at View.engine (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:104656:23)
    at View.render (C:\Users\Mikser\documents\git\my-angular-universal\dist\server.js:130741:8)
Run Code Online (Sandbox Code Playgroud)

我使用的npm软件包的版本当前是最新的:

  • @角度/ *-@ 5.2。*
  • @角度/ cli @ 1.7.3

除了ts-loader之外,由于它无法正常工作,因此不得不对其进行降级:

  • ts-loader @ 3.5.0

因此,如果有人对如何进行这项工作有任何信息,将不胜感激!或者,也许您知道一些同时配置了Angular Universal App的项目模板--dev以及其--prod构建和能力--watch?

node.js webpack angular-cli angular-universal angular

7
推荐指数
1
解决办法
2748
查看次数

在构造角度6库时为导出的符号生成的元数据中遇到错误

从我的库中执行'ng build'时出现以下错误.

我目前正在使用Angular 6,但我相信这个错误与版本无关.

/home/rafaelvicio/desenv/my-lib/arquitetura-web/projects/pf-siseg/src/lib/keycloak-service/keycloak.service.ts:13:1:为导出的符号'KeycloakService'生成的元数据中遇到错误:
/home/rafaelvicio/desenv/my-lib/arquitetura-web/projects/pf-siseg/src/lib/keycloak-service/keycloak.service.ts:18 : 12:收集的元数据包含一个错误,将在运行时:只能初始化变量和常量,因为模板编译器需要此变量的值.
{"_ _ symbolic":"错误","消息":"变量未初始化","行":17,"字符":11}错误:/ home/rafaelvicio/desenv/my-lib/arquitetura-web/projects/pf-siseg/src/lib/keycloak-service/keycloak.service.ts:13:1:为导出的符号'KeycloakService'生成的元数据遇到错误:
/home/rafaelvicio/desenv/my-lib/arquitetura-web/projects /pf-siseg/src/lib/keycloak-service/keycloak.service.ts:18:12:收集的元数据包含将在运行时报告的错误:只能初始化变量和常量,因为此变量的值为模板编译器需要的.
{"_ _ symbolic":"错误","消息":"变量未初始化","行":17,"字符":11} at/home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@ angular/compiler-cli/src/metadata/collector.js:707:31位于validateMetadata的Array.forEach()(/ home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@ angular/compiler-cli/src/metadata/collector.js:695:46)在MetadataCollector.getMetadata(/home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@angular/compiler-cli/src/metadata/collector.js:550 :21)在Object.getSourceFileMetadata上的MetadataCache.getMetadata(/home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@angular/compiler-cli/src/transformers/metadata_cache.js:86:41) home.rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js:112:56)at Object.readMetadata(/ home/rafaelvicio/desenv/my-lib TsompilerAotCompiler上的/arquitetura-web/node_modules/@angular/compiler-cli/src/transformers/metadata_reader.js:46:37)StaticSymbolResolver.getModuleMetadata中的TypeCheckHostAdapter.getMetadataFor(/home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@angular/compiler-cli/src/transformers/compiler_host.js:464:38)(/ home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules/@angular/compiler/src/aot/static_symbol_resolver.js:480:49)在StaticSymbolResolver._createSymbolsOf(/ home/rafaelvicio/desenv/my-lib/arquitetura-web/node_modules) /@angular/compiler/src/aot/static_symbol_resolver.js:268:33)

keycloak.service.ts:

import { Injectable } from '@angular/core';
import { KeycloakLoginOptions } from './keycloak.d';

import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';

import * as Keycloak from './keycloak';

export type KeycloakClient = Keycloak.KeycloakInstance;
type InitOptions = Keycloak.KeycloakInitOptions;

@Injectable()
export class KeycloakService {

    constructor(private http: HttpClient) { }

    static …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular angular-library angular-cli-v6

7
推荐指数
3
解决办法
2638
查看次数

Angular Uncaught TypeError:构建--prod后,e不是构造函数(在ng serve上工作)

将我的角度应用程序上传到生产环境时遇到问题。该应用程序在开发中运行良好,并且在投入生产之前也可以正常工作。

要构建我的应用程序,我正在使用:

ng build --prod --base-href="/site/" 
Run Code Online (Sandbox Code Playgroud)

该应用程序已构建,但带有以下警告:

WARNING in ./src/app/eco-header/eco-header.component.ngfactory.js 138:299-319 "export 'MAT_ICON_LOCATION' (imported as 'i9') was not found in '@angular/material/icon'

WARNING in ./node_modules/@angular/material/dialog/typings/index.ngfactory.js 20:1247-1265 "export 'ScrollingModule' (imported as 'i7') was not found in '@angular/cdk/scrolling'

WARNING in ./node_modules/@angular/material/dialog/typings/index.ngfactory.js 20:1267-1285 "export 'ScrollingModule' (imported as 'i7') was not found in '@angular/cdk/scrolling'

WARNING in ./node_modules/@angular/material/icon/typings/index.ngfactory.js 20:327-347 "export 'MAT_ICON_LOCATION' (imported as 'i1') was not found in '@angular/material/icon'
Run Code Online (Sandbox Code Playgroud)

当我尝试加载页面时,出现以下错误:

Uncaught TypeError: e is not a constructor
    at main.1ebe20842d3713f62535.js:1
    at Wl (main.1ebe20842d3713f62535.js:1)
    at main.1ebe20842d3713f62535.js:1
    at new …
Run Code Online (Sandbox Code Playgroud)

typescript angular-cli angular

7
推荐指数
1
解决办法
3096
查看次数

在Angular CLI项目结构中创建ionic 4应用

我正在寻找一种“离子启动”项目并将其保存在现有Angular CLI解决方案(已经包含一个Web应用程序和一个lib)的projects文件夹中的方法。

ionic-cli angular-cli ionic4

7
推荐指数
1
解决办法
727
查看次数