当我在 angularjs 2 中配置 bootstrap 时,我在此链接中遇到了以下步骤,
如何将 bootstrap 添加到 angular-cli 项目
npm i bootstrap@next
Run Code Online (Sandbox Code Playgroud)
我明白如果我们运行以下命令,
npm i -S bootstrap@4.0.0-alpha.4
Run Code Online (Sandbox Code Playgroud)
然后这将安装 bootstrap alpha 版本。但是如果我们给出@next,将安装哪个版本?
还有 --save 和 @next 之类的,
npm i bootstrap@next --save
Run Code Online (Sandbox Code Playgroud)
推荐哪个?以及我们如何确认已安装版本的版本?
我有很多模块的应用程序。我正在使用 ngx-translate 来实现多语言功能。但是,它不起作用。
i18n.module.ts
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { TranslateModule, TranslateLoader } from "@ngx-translate/core";
import { TranslateHttpLoader } from "@ngx-translate/http-loader";
import { Http } from "@angular/http";
import { I18NComponent } from "./i18n.component";
@NgModule({
declarations: [I18NComponent],
imports: [
BrowserModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: (http: Http) => new TranslateHttpLoader(http, 'i18n/', '.json'),
deps: [Http]
}
})
],
exports: [I18NComponent]
})
export class I18NModule { }
Run Code Online (Sandbox Code Playgroud)
i18n.组件.ts
import { Component } from '@angular/core'; …Run Code Online (Sandbox Code Playgroud) internationalization angular-cli ng2-translate ngx-translate angular
我最近从css转到了scss.
突然之后,我的项目在重建后加载页面的速度非常慢.(30-50秒)
我除了添加scss而不是css之外什么也没做.刚刚更改了文件并更改了.angular-cli中的设置以改为使用scss.
如果我能分享更多信息以帮助排除故障,请告诉我们.
我不知道为什么会这样.
终奌站:
webpack: Compiling...
Hash: 528351f97868ee9f6cc1
Time: 1857ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {4} [initial]
chunk {1} main.bundle.js, main.bundle.js.map (main) 46.1 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 26.6 kB {4} [initial]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 4.2 MB [initial]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
webpack: Compiled successfully.
webpack: Compiling...
Hash: b4d9b9ae09285a8f41b1
Time: 350ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 178 kB {4} [initial]
chunk {1} main.bundle.js, main.bundle.js.map (main) 44.9 …Run Code Online (Sandbox Code Playgroud) 在我的angular cli项目中,我需要引用不是节点包的外部js库.因此,它们不会位于node_modules文件夹下,因为它们不是由npm安装的.这些是松散的js文件.
下面的链接解释了我们如何在.angular-cli.json文件的脚本数组中引用它们.但是,如果它们不是节点模块,它不会告诉外部js文件应该在angular cli项目的文件夹结构中添加到何处. Angular Cli Webpack,如何添加或捆绑外部js文件?
我正在开发一个Angular库,我正在与AOT编译兼容.我已经开始使用一些gulp任务了ngc,但是我更喜欢使用,@ngtools/webpack因为它允许我使用SASS和PUG作为我的样式和模板的更直接的方法.但是,我找不到从其虚拟文件系统中获取声明或元数据文件的方法.有没有办法发出这些文件?
使用以下命令安装 Angular cli:
npm -g install angular/cli
Run Code Online (Sandbox Code Playgroud)
使用节点 8.6 会产生此错误:
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/angular/cli.git
npm ERR!
npm ERR! Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
npm ERR!
npm ERR! exited with error code: 128
npm ERR! A complete log of this run can be found in:
npm ERR! …Run Code Online (Sandbox Code Playgroud) 我需要在字符串类上有一些全局原型函数.例如.
string.prototype.trimWhiteSpaces = function () {
return this.replace(/ +/g, '');
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Angular CLI,我希望Angular 4应用程序中的所有字符串都可以访问此函数.我已将代码段添加到一个名为的文件中,prototypes.js并在.angular-cli.json我加载的文件中
"scripts": [
"assets/js/prototypes.js",
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js",
"../node_modules/moment/min/moment.min.js"
],
Run Code Online (Sandbox Code Playgroud)
但是,当我编译项目时,我不断收到以下错误
类型'string'上不存在属性'trimWhiteSpaces'.
如何在我的应用程序中访问这些功能
PrimeNg是一个包含许多组件的大型库。我的角度应用程序仅使用其中很少的组件。我正在使用AngularCLI构建此应用程序。当我构建它时,vendor.bundle具有primeng库的全部内容。这使得捆绑包的大小很大(〜4MB)。
如何仅包含必需的组件而不包含完整的库?
今天,sudeenly我开始得到这个错误 "无法读取属性'NullLogger'未定义", 同时尝试在我的角度4应用程序中添加一个组件(ng gc abc).当我在谷歌搜索它时,人们建议我们需要将我们的cli版本更新到1.4.10.但问题是为什么我们现在为1.4.10以下的所有angular/cli版本得到这个错误? .我现在不想更新我的CLI版本.有谁知道它为什么会发生?
以下是我的package.json文件,
"dependencies": {
"@angular/animations": "^4.4.6",
"@angular/common": "^4.4.6",
"@angular/compiler": "^4.4.6",
"@angular/core": "^4.4.6",
"@angular/forms": "^4.4.6",
"@angular/http": "^4.4.6",
"@angular/platform-browser": "^4.4.6",
"@angular/platform-browser-dynamic": "^4.4.6",
"@angular/router": "^4.4.6",
"angular2-csv": "^0.2.5",
"bootstrap": "^3.3.7",
"classlist.js": "^1.1.20150312",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"lodash": "^4.17.4",
"ng-select": "^1.0.0-rc.3",
"ng2-dragula": "^1.5.0",
"reflect-metadata": "^0.1.10",
"rxjs": "^5.4.2",
"toastr": "^2.1.2",
"underscore": "^1.8.3",
"web-animations-js": "^2.3.1",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.4.7",
"@angular/compiler-cli": "^4.4.6",
"@angular/language-service": "^4.4.6",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"@types/toastr": "^2.1.35",
"codelyzer": "~3.2.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": …
我正在尝试在应用程序中使用 Angular Material 库创建故事书nx,但我无法显示该库附带的样式。因此组件会呈现,但没有随之而来的样式。我已将组件添加到 Storybook 中,如下所示:
export default {
title: 'Buttons',
component: ButtonComponent,
decorators: [
moduleMetadata({
imports: [
MatButtonModule
],
}),
]
} as Meta<ButtonComponent>;
Run Code Online (Sandbox Code Playgroud)
此屏幕截图显示了主按钮,但没有获得正确的紫色样式。
我该如何将这样的内容导入 Storybook 以便主题得以体现?
@import '@angular/material/prebuilt-themes/deeppurple-amber.css';
Run Code Online (Sandbox Code Playgroud)
这也是一个nx应用程序,所以没有angular.jsonaproject.json和 a workspace.json。我尝试将主题添加到project.json下面,但不起作用,我认为它需要以某种方式直接传递到故事书而不是在project.json内部(这将适用于应用程序本身而不是故事书)?
"build": {
"options": {
"styles": [
"node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css"
],
"scripts": []
}
},
Run Code Online (Sandbox Code Playgroud)
使用Angular Material "13.2.3"、"@nrwl/storybook": "13.8.3",然后使用这些附加库:
"@storybook/addon-essentials": "6.5.0-alpha.41",
"@storybook/addon-knobs": "6.4.0",
"@storybook/addons": "^6.5.0-alpha.41",
"@storybook/angular": "6.5.0-alpha.41",
"@storybook/api": "6.5.0-alpha.41",
"@storybook/builder-webpack5": "6.5.0-alpha.41",
"@storybook/core-server": "6.5.0-alpha.41",
"@storybook/manager-webpack5": …Run Code Online (Sandbox Code Playgroud) angular-material angular-cli storybook nrwl-nx angular-storybook
angular-cli ×10
angular ×7
typescript ×2
angular2-aot ×1
css ×1
javascript ×1
ng-bootstrap ×1
node.js ×1
nrwl-nx ×1
primeng ×1
prototype ×1
sass ×1
ssh ×1
storybook ×1
webpack ×1