我在用
在编译Angular 6应用程序时,我遇到了错误,下面只是第一个
ERROR in ./src/app/web.service.ts
Module not found: Error: Can't resolve 'rxjs/add/operator/toPromise' in
'C:\Node\ang\frontend\src\app'
Run Code Online (Sandbox Code Playgroud)
我的web.service.ts代码
import { Http, Headers, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
export class WebService{
constructor(private http:Http){
}
getMessages(){
return this.http.get("http://localhost:2000/messages").toPromise();
}
}
Run Code Online (Sandbox Code Playgroud)
我的app.module.ts代码
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import {MatButtonModule,
MatCardModule,
MatSnackBarModule,
MatToolbarModule,
MatInputModule} from '@angular/material';
import { AppComponent } from './app.component';
import { WebService …Run Code Online (Sandbox Code Playgroud) 要求: 我如何转换以下 json 格式。
从 :
[
{"u0":{"user_id":"124", "name":"Eloise R. Morton"}},
{"u1":{"user_id":"126", "name":"Mary S. Williams"}}
]
Run Code Online (Sandbox Code Playgroud)
到 :
{
"u0":{"user_id":"124", "name":"Eloise R. Morton"},
"u1":{"user_id":"126", "name":"Mary S. Williams"}
}
Run Code Online (Sandbox Code Playgroud)
我想从 JSON 中删除/删除第一个和最后一个方括号。
PHP代码:
$sql = "SELECT * FROM user_list";
$result = $conn->query($sql);
$user_count=0;
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$user_count_id="u".$user_count;
$user_count++;
$user_list[]= array($user_count_id=>$row);
}
} else {
echo "0 results";
}
echo json_encode($user_list);
$conn->close();
Run Code Online (Sandbox Code Playgroud)
Javascript代码:
function update_user_list(){
//Fetch data
$.ajax( "user_list.php" ).done(function(json) …Run Code Online (Sandbox Code Playgroud) I am trying to change the default pie chart color. but all 3 pie chart arc showing red color. Apply the first color in pieColor array to all arc. I am using chart.js 2.9.3, ng2-charts 2.3.0 & angular 8. Also, I am trying a different color format like hex code or RGB but not working.
pie-chart.component.html
<div class="chart-wrapper">
<canvas baseChart
[data]="doughnutChartData"
[labels]="doughnutChartLabels"
[colors]="pieColor
[chartType]="doughnutChartType">
</canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
pie-chart.component.ts
import { Component } from '@angular/core';
import { ChartType } from 'chart.js';
import …Run Code Online (Sandbox Code Playgroud)