我正在研究angular2"2.0.0-rc.1"但是zoneJS给出了以下错误
Error: Uncaught (in promise): Expected 'styles' to be an array of strings.
at resolvePromise (zone.js:538)
at zone.js:515
at ZoneDelegate.invoke (zone.js:323)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (eval at <anonymous> (vendor.js:335), <anonymous>:45:41)
at ZoneDelegate.invoke (zone.js:322)
at Zone.run (zone.js:216)
at zone.js:571
at ZoneDelegate.invokeTask (zone.js:356)
at Object.NgZoneImpl.inner.inner.fork.onInvokeTask (eval at <anonymous> (vendor.js:335), <anonymous>:36:41)
at ZoneDelegate.invokeTask (zone.js:355)
Run Code Online (Sandbox Code Playgroud)
我的代码如下
let styles = require('./dashboard.css');
let template = require('./dashboard.html');
declare var zingchart:any;
@Component({
selector: 'dashboard',
directives: [ RouterLink, CORE_DIRECTIVES, FORM_DIRECTIVES ],
template: template,
styles: [ styles ]
})
Run Code Online (Sandbox Code Playgroud) 昨天我做了一些关于 nodeJS 的演讲。有人问我以下问题:
我们知道 nodeJS 是一个单线程服务器,有几个请求到达服务器,它将所有请求推送到事件循环。如果两个请求同时到达服务器怎么办,服务器将如何处理这种情况?
我猜到了一个想法,回复如下:
我想没有两个 http 请求可以同时到达服务器,所有请求都来自一个套接字,因此它们将在队列中。Http请求格式如下:
请求的时间戳包含在它的标头中,它们可能会根据标头中的时间戳被推送到事件循环。
但我不确定我给了他正确还是错误的答案。
现在我正在按以下顺序在我的项目中添加脚本:
window.top.ak.getScript([
window.top.akContextPath + "/scripts/css/xxx.css",
window.top.akContextPath + "/scripts/js/xxx.min.js",
window.top.akContextPath + "/scripts/js/polyfills.min.js",
window.top.akContextPath + "/scripts/js/jquery.min.js",
currHost + "/components/lib/lodash.min.js",
window.top.akContextPath + "/scripts/js/moment.min.js",
window.top.akContextPath + "/scripts/js/angular.min.js"
], function() {
window.top.ak.getScript([
window.top.akContextPath + "/scripts/js/angular-messages.js",
window.top.akContextPath + "/scripts/js/angular-ui-router.js",
window.top.akContextPath + "/scripts/js/angular-animate.js",
currHost + "/components/lib/toaster.min.js",
window.top.akContextPath + "/scripts/js/ui-grid.min.js",
currHost + "/components/lib/defiant.min.js",
window.top.akContextPath + "/scripts/js/xxx-ui.js",
currHost + "/components/lib/polyfill-resize.js",
currHost + "/components/lib/draggable-rows.js",
currHost + "/components/lib/moment-with-locales.js",
], function() {
window.top.ak.getAsset([
currHost + "/components/common.bundle.js",
currHost + "/components/myApp." + pagePath + ".bundle.js"
], document);
}, document);
}, document);
Run Code Online (Sandbox Code Playgroud)
其中getScript/ …
我使用ng-bootstrap替代angular2中的ui-bootstrap.
我的html如下:
<div class="row" style="height: 100%;">
<div class="col-12">
<div class="container" id="contentMain">
<div class="card-my-profile">
<div class="card-image">
<div class="image-wrap">
<div class="image-placholder" data-firstletter="S"></div>
</div>
</div>
<div class="clearfix card-fluid">
<div class="">
<h4 class="title-card">Priya</h4>
<div><span class="item-type">Title:</span> Job title</div>
<div><span class="item-type">Location:</span> Bangalore</div>
</div>
<div class="">
<div><span class="item-type">Contact:</span> 9876543210</div>
<div><span class="item-type">Email:</span> priya@gmail.com</div>
<div><span class="item-type">Experience:</span> 9 years</div>
</div>
</div>
<div class="card-buttons">
<a href class="btn btn-success btn-rounded text-uppercase">Resume <i class="bi_interface-tick small"></i> </a>
<div class="text-right">
<a class="inherit small" href>Update?</a>
</div>
<a [hidden]="!isNotUploaded" href class="btn btn-default btn-rounded text-uppercase">Upload CV</a>
<ul class="list-inline …Run Code Online (Sandbox Code Playgroud) angular-ui-bootstrap angular-ui-bootstrap-tab ng-bootstrap angular
我是angular指令的新手,所以我创建了如下指令:
import { Directive, ElementRef, Input, Output } from '@angular/core';
@Directive({
selector: "[bonusCard]"
})
export class BonusCard {
@Input() bonus: string;
@Input() amount: string;
@Input() isSeleted: string;
constructor(private el: ElementRef){
el.nativeElement.innerHTML = this.getTemplate()
}
getTemplate(){
return ''+
'<div>'+
'<div class="bonus">'+this.bonus+'</div>'+
'<div class="amount">'+this.amount+'</div>'+
'<div class="radio '+(this.isSeleted?'is_seleted':'')+'"></div>'+
'</div>' +
'';
}
}
Run Code Online (Sandbox Code Playgroud)
我在模板中使用此指令,如下所示:
<div class="column col-3" *ngFor="let b of bonusJson;let i = index" bonusCard [bonus]="b.bonus" [amount]="b.amount" [isSeleted]="i==activeBonus"></div>
Run Code Online (Sandbox Code Playgroud)
其中变量定义如下:
bonusJson = [{
bonus:1500,
amount:2000
},{
bonus:1000,
amount:1000
},{
bonus:500,
amount:500
},{
bonus:0,
amount:100 …Run Code Online (Sandbox Code Playgroud) angular ×3
angularjs ×1
directive ×1
http ×1
javascript ×1
momentjs ×1
ng-bootstrap ×1
node.js ×1
request ×1
tcp ×1
typescript ×1
zone ×1
zonejs ×1