Ember CLI有一个命令(ember addon <addon-name>),它将设计一个新项目,通过npm安装到其他Ember CLI项目中.这些"插件"项目也可以使用内置的"虚拟应用程序"独立构建和提供,该虚拟应用程序充当插件的假消费者,用于测试和演示目的.这对于快速创建在业务应用程序之间共享但也独立部署的样式指南/组件库非常有用.
我正在为Angular CLI项目寻找一个等价物,并且希望CLI能够提供类似的方法来创建插件,因为它基于Ember CLI.是否可以从另一个Angular CLI应用程序中使用Angular CLI应用程序,或者我是否必须使用手动(gulp/grunt)构建过程创建自己的"插件"?
谢谢!
我正在使用:
我有一个新的Angular CLI项目,尽管main.bundle.js文件中显示了组件样式,也没有加载组件样式,并且没有抛出任何路径错误(不再)。
该angular-cli.json文件具有defaults.styleExt: "scss"和apps.styles: ["styles.scss","path/to/bootstrap.css"]。defaults.inline样式和模板均为假。
全局和Bootstrap样式正在加载,但组件中没有加载。
|- src
|- index.html
|- styles.scss
|- scss
|- _colors.scss
|- _modals.scss
|- _overrides.scss
|- _utils.scss
|- app
|- components
|- app-header
|- app-header.component.ts
|- app-header.component.html
|- app-header.component.scss
|- pages
|- app-routing.module.ts
|- app.component.ts
|- app.module.ts
Run Code Online (Sandbox Code Playgroud)
@import './scss/_colors';
@import './scss/_overrides';
@import './scss/_utils';
@import './scss/_modals';
html, body {
width: 100%;
height: 100%;
font-family: 'Roboto', …Run Code Online (Sandbox Code Playgroud) 我只是尝试使用angular-cli创建一个新项目,然后运行服务器,但它停止了一个有趣的消息:Error: No errors.
我以这种方式更新它(希望它有帮助): npm uninstall -g angular-cli ; npm cache clean ; npm install -g angular-cli@latest
但这是同一个问题.请在此处查看所有消息:http://pastebin.com/AhbdHRR7
Fortunalty,我的其他项目仍然有效.
但是新的会发生什么?
JPM
node -v ==> v6.9.4
npm -v ==> 4.1.2
ng version ==> angular-cli: 1.0.0-beta.26
Run Code Online (Sandbox Code Playgroud) 我只想知道是否可以运行Angular2 cli,服务器渲染类似于Angular2 universal?
问题是爬虫无法使用Angular2 cli读取网站,这对SEO很重要.
是否可以轻松地将角度通用添加到角度cli中,或者它是来自不同的?
我有一个Angular项目设置与angular-cli.我想将Roboto字体与我的网站捆绑在一起,所以我这样做是因为我在styles.scss中声明它
/* You can add global styles to this file, and also import other style files */
@import url('https://fonts.googleapis.com/css?family=Roboto');
// Set Global Font
body {
font-family: 'Roboto', sans-serif;
margin: 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,似乎字体默认为sans-serif而不是Roboto.我尝试在index.html中添加一个链接,效果相同.
PS不确定是否相关,但我也添加了材料图标
// Import Material Icons
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2') format('woff2'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff') format('woff'),
url('../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf') format('truetype');
}
Run Code Online (Sandbox Code Playgroud)
在同一个文件中,这可能会对项目产生影响吗?
ng build将文件导出到dist文件夹,如下所示
index.html
main.bundle.js
styles.bundle.js
...
Run Code Online (Sandbox Code Playgroud)
我希望脚本在子文件夹中
*index.html
scripts/main.bundle.js
scripts/styles.bundle.js
...*
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我正在使用angular cli建立一个包含多种语言的网站。我使用ng2-translate进行翻译。
我导入在angular-cli.json中定义的languages.json文件:
"assets": [
"assets",
"fonts",
"languages.json"
],
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我使用require检索数据:
this.languages = require('../../../../languages.json');
Run Code Online (Sandbox Code Playgroud)
加载json文件有效。部署后,我尝试更改(添加或删除)languages.json中的某些语言,但是即使json文件在dist中更新,更改也不会显示在网站上。我可以更新网站的唯一方法是更改原始json文件,再构建应用程序的另一个版本并再次部署。是否可以通过仅更新dist中的json文件来更改网站?
为了澄清起见,languages.json包含一个语言代码数组,用于定义网站的语言选择器中显示的语言。我希望使用此配置来更改网站中显示的语言,而无需重建应用程序。
这是我的package.json:
{
"name": "myApp",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"dev": "ng serve --environment=dev",
"acc": "ng serve --environment=acc",
"prod": "ng serve --environment=prod",
"build:dev": "ng build --environment=dev",
"build:acc": "ng build --environment=acc",
"build:prod": "ng build --environment=prod",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.0.2",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/core": …Run Code Online (Sandbox Code Playgroud) 我在我的项目中使用PrimeNg GMap,但收到错误"ReferenceError:google未定义"我正在关注此链接以获取文档 https://www.primefaces.org/primeng/#/gmap.请告诉我如何为GMap添加api密钥. 错误图片
我的组件
import {GMapModule} from 'primeng/primeng';
@Component({
selector: 'mycomponent',
templateUrl: './mycomponent.component.html',
[})
export c][1]lass MyComponent implements OnInit {
options: any;
overlays: any[];
ngOnInit() {
this.options = {
center: {lat: 36.890257, lng: 30.707417},
zoom: 12
};
this.overlays = [
new google.maps.Marker({position: {lat: 36.879466, lng: 30.667648}, title:"Konyaalti"}),
new google.maps.Marker({position: {lat: 36.883707, lng: 30.689216}, title:"Ataturk Park"}),
new google.maps.Marker({position: {lat: 36.885233, lng: 30.702323}, title:"Oldtown"}),
new google.maps.Polygon({paths: [
{lat: 36.9177, lng: 30.7854},{lat: 36.8851, lng: 30.7802},{lat: 36.8829, lng: 30.8111},{lat: 36.9177, lng: 30.8159} …Run Code Online (Sandbox Code Playgroud) 我希望通过SSL提供我的应用程序之前我有这个脚本:
ng serve --ssl --ssl-key "pathtokey\key.crt"
Run Code Online (Sandbox Code Playgroud)
我想在新的angular.json中添加SSL但是当我尝试添加它时我得到了错误:
Schema validation failed with the following errors:
Data path "" should NOT have additional properties(ssl).
Run Code Online (Sandbox Code Playgroud)
在角度cli 6中使用SSL的正确方法是什么?
我已经从官方的角度博客https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2阅读了这种解释
Schematics是现代Web的工作流程工具;它可以将转换应用于您的项目,例如创建新组件,或更新代码以修复依赖项中的重大更改。或者,您可能想向现有项目添加新的配置选项或框架。
我什至按照博客中的示例生成新原理图
npm install -g @ angular-devkit / schematics-cli
原理图空白--name = my-component
之后,我打开了my-component文件夹。这就是我开始困惑的地方...生成的文件可能是由
ng新
唯一的不同是上述命令将产生比原理图更多的文件。根据描述:通过原理图完成了新组件的创建和代码的更新,但这可以通过有角度的CLI使用“ ng new”来完成
angular-cli ×10
angular ×8
javascript ×2
sass ×2
typescript ×2
angular6 ×1
css ×1
json ×1
primeng ×1