let startingColorOfGradient = UIColor(colorLiteralRed: 255/255, green:
255/255, blue: 255/255, alpha: 1.0).cgColor
let endingColorOFGradient = UIColor(colorLiteralRed: 251/255, green:
247/255, blue: 234/255, alpha: 1.0).cgColor
let gradient: CAGradientLayer = CAGradientLayer()
Run Code Online (Sandbox Code Playgroud)
错误:
'init(colorLiteralRed:green:blue:alpha :)'在Swift 4.0中被淘汰(Swift._ExpressibleByColorLiteral)
如果init(colorLiteralRed:,green:,blue:,alpha:)在Swift 4中弃用,如何使用渐变颜色?
我有一个带有表单的angular4应用程序.在这个我输入一个百分比.所以,我想阻止值为0到100之间,我试图添加的输入min="0"和max="100",但我还可以输入高于100或小于0的号码.
模板
<md-input-container>
<input type="number"
maxlength="3"
min="0"
max="100"
required
mdInput
placeholder="Charge"
[(ngModel)]="rateInput"
name="rateInput">
<md-error>Required field</md-error>
</md-input-container>
Run Code Online (Sandbox Code Playgroud)
你知道我怎么做吗?
我正在使用ionicv2和Adobe Creative SDK构建照片编辑应用程序.我已经成功实施了创意SDK.
在CSDK成功返回已编辑文件的URL后,我将包含段的页面与文件URL一起推送.
问题出在第二页,当我点击该段时,它不会切换.只有在我点击页面内的输入时才会切换.
我尝试在没有CSDK的情况下进行操作,它运行没有任何问题.
我的代码:
loadCamera(sourceType){
const options: CameraOptions = {
quality: 100,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE,
sourceType: sourceType
}
this.camera.getPicture(options).then((imageData) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64:
let base64Image = 'data:image/jpeg;base64,' + imageData;
var thisModule = this;
function success(newUrl) {
console.log("Success Editing!", newUrl);
thisModule.goToCreate(newUrl);
}
function error(error) {
console.log("Error!", error);
}
/* Optional `options` object. See API guide for usage. */
var options = …Run Code Online (Sandbox Code Playgroud) 我正在使用一个breadcrumbs组件来订阅router.events.问题是第一次加载组件时,它不会触发订阅.
ngOnInit(): void {
console.log("oninit beradcumbs");
this.router.events.filter(event => event instanceof NavigationEnd).subscribe(event => {
this.breadcrumbs = [];
let currentRoute = this.route.root,
url = '';
do {
const childrenRoutes = currentRoute.children;
currentRoute = null;
childrenRoutes.forEach(route => {
if (route.outlet === 'primary') {
const routeSnapshot = route.snapshot;
url += '/' + routeSnapshot.url.map(segment => segment.path).join('/');
this.breadcrumbs.push({
label: route.snapshot.data,
url: url
});
currentRoute = route;
}
});
} while (currentRoute);
console.log("Breadcumbs",this.breadcrumbs);
});
}
Run Code Online (Sandbox Code Playgroud)
单击具有routerLink属性的链接时,订阅将发出值,并且工作正常.我将我的项目与使用Augury的工作项进行了比较,并且在面包屑组件中,路由器的状态如下所示:不工作的路由器
工作的一个:工作路由器
现在让我,如果您需要更多信息帮助:)提前感谢!
我对 Angular 4 有点问题。下面的错误被抛出
错误:ExpressionChangedAfterItHasBeenCheckedError:检查后表达式已更改。以前的值:'225px'。当前值:'-21150px'。
这是我的 html:
<div class="channelRow" *ngFor="let epgChannel of channelGroupEpg?.epgChannels">
<div class="epgChannelList">
{{epgChannel.channel.name}}
</div>
<template ngFor let-epgDate [ngForOf]="epgChannel.dates">
<div class="epgEntry"
*ngFor="let epgProgram of epgDate.programs"
[style.width]="getWidth(epgProgram, epgDate.date)"
(click)="selectProgram(epgProgram)"
data-toggle="modal"
data-target="#detailModal">
{{epgProgram.title}}
</div>
</template>
</div>
Run Code Online (Sandbox Code Playgroud)
这就是错误的来源:
getWidth(program: EPGProgram, date: Date) {
let min = this.helperService.getDurationByProgramInMinutes(program);
let startDate = new Date(program.start.getFullYear(), program.start.getMonth(), program.start.getDate(), 0, 0, 0, 0);
let stopDate = new Date(program.stop.getFullYear(), program.stop.getMonth(), program.stop.getDate(), 0, 0, 0, 0);
if (startDate.getTime() !== date.getTime()) {
let minNextDay = this.helperService.getMinutesToNextDay(program.start, date);
min = …Run Code Online (Sandbox Code Playgroud) 我有一个简单的指令,根据接收的属性为给定的HTML元素添加一些属性.
<button class="btn btn-blue x-large" [myDirective]="{ some_json_data: true }">
Unfold
</button>
Run Code Online (Sandbox Code Playgroud)
该myDirective指令只是在ngOnInit钩子中做了一些逻辑并装饰了ElementRef原生元素(在这种情况下是按钮)添加属性,没有什么复杂的.
ngOnInit(): void {
const el: Element = this.element.nativeElement;
this.decorate(el, this.myDirective);
}
Run Code Online (Sandbox Code Playgroud)
基于给定的逻辑(在myDirective装饰中)我想向ElementRefat 引用的元素添加工具提示(这是另一个指令)myDirective.
如何手动挂载指令以及如何将其添加到元素(ViewContainerRef)?
budget:number=50000;
{{budget | currency:'USD':true}}
Run Code Online (Sandbox Code Playgroud)
上面的代码显示了这样的预算
$50,000.00
Run Code Online (Sandbox Code Playgroud)
但我希望它像这样显示
$50,000
Run Code Online (Sandbox Code Playgroud) 我有一个大型项目,直到现在都在 webpack 上运行,并且在 angular@4.3.3 上运行良好。今天我计划将其转移到 ng-cli 以利用通用等功能。一切都运行良好,除了当我尝试在 prod/prod+aot 中构建项目时,我得到:最大调用堆栈大小超出。
检查了问题的各个地方,大多数人都告诉检查循环依赖。但是根据最新的 cli@1.2.7,循环依赖应该显示为构建时间,但事实并非如此。我计划增加节点虚拟机堆栈的大小,但无法实现。我不想使用 ng 弹出并再次陷入 webpack 的混乱中。
cli@1.2.7 还有其他一些方法或解决方案吗
谢谢
包.json
{
"name": "test-project",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "~4.3.3",
"@angular/compiler": "~4.3.3",
"@angular/core": "~4.3.3",
"@angular/forms": "~4.3.3",
"@angular/http": "~4.3.3",
"@angular/animations": "~4.3.3",
"@angular/flex-layout": "^2.0.0-beta.8",
"@angular/material": "^2.0.0-beta.8",
"@angular/cdk": "^2.0.0-beta.8",
"@angular/platform-browser": "~4.3.3",
"@angular/platform-browser-dynamic": "~4.3.3",
"@angular/platform-server": "~4.3.3",
"@angular/router": "~4.3.3",
"angular2-highcharts": "~0.5.5",
"@types/highcharts": "~4.2.57", …Run Code Online (Sandbox Code Playgroud) ng服务命令后,我在Angular 4项目中出现以下错误.
./src/app/Utils/config.service.ts有多个模块的名称只有外壳不同.在使用其他case-semantic编译文件系统时,这可能会导致意外行为.使用相同的套管.比较这些模块标识符:*D:\ ANGULAR\siteprice.org \node_modules\@ngtools\webpack\src\index.js!D:\ ANGULAR\siteprice.org\src\app\Utils\config.service.ts使用者1个模块,即D:\ ANGULAR\siteprice.org \node_modules\@ngtools\webpack\src\index.js!D:\ ANGULAR\siteprice.org\src\app\utils\email.service.ts*D:\ ANGULAR\siteprice.org \node_modules\@ngtools\webpack\src\index.js!D:\ ANGULAR\siteprice.org\src\app\utils\config.service.ts由2个模块使用,即D:\ ANGULAR\siteprice.org \node_modules\@ngtools\webpack\src\index.js!D:\ ANGULAR\siteprice.org\src\app\app.module.ts
config.service.ts文件:
import { Injectable } from '@angular/core';
@Injectable()
export class ConfigService {
_apiURI : string;
constructor() {
this._apiURI = 'http://www.example.com/xyz/api/';
}
getApiURI() {
return this._apiURI;
}
getApiHost() {
return this._apiURI.replace('api/','');
}
}
Run Code Online (Sandbox Code Playgroud)
email.service.ts:
import { Injectable } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';
import {Observable} from 'rxjs';
import 'rxjs/add/operator/map';
import { ConfigService } from '../Utils/config.service';
import { Email } from '../Models/email'; …Run Code Online (Sandbox Code Playgroud) 我有一个数组,其中包含商品有图像名称的信息.随着*ngIf它应该显示任何图像或"无图像".但内部的属性绑定*ngIf不起作用.这甚至可能吗?
<div class="m-c-o" *ngFor="let offer of offers">
<div class="m-c-p" *ngIf="showOffers">
<div class="m-c-img-c">
<img *ngIf="{{ offer.U_D__IMAGE }} != false" src="{{ imagePath + offer.U_D__IMAGE }}">
<div *ngIf="{{ offer.U_D__IMAGE }} === false">
<i class="materials-icons">photo_camera</i>
<div class="m-c-img-ni">No Images</div>
</div>
</div>
</div>
</div
Run Code Online (Sandbox Code Playgroud)