logo
down
shadow

How to pass a array value as color in Angular 4


How to pass a array value as color in Angular 4

By : user3418
Date : November 21 2020, 03:00 PM
help you fix your problem I'm new in Angular and in stackoverflow. I need to know if can I pass the value of an array in the element bidding in Angular 4. , Just should use style.background input:
code :
<div *ngIf="student">
  Student: <a href="#" (click)="clicked()">{{student?.name}}</a>
  <br/>
  <div *ngIf="student?.isJedi">
  Jedi Temple: {{student?.temple}} <br/>
  </div>
  <div #jediSign class="jediSign" [style.background]="isJediBackgroundColor(student)" ></div>
  <button (click)="student.isJedi = !student.isJedi">Is Jedi?
  </button>
 </div>
isJediBackgroundColor(student) {
  return student.isJedi ? student.color : '';
}
(click)="student.isJedi = !student.isJedi"


Share : facebook icon twitter icon
Set <tr> color on change of angular array

Set <tr> color on change of angular array


By : user2839327
Date : March 29 2020, 07:55 AM
I hope this helps . You can flag it as changed.
Set car.changed to true when you've changed it
code :
$scope.car[0].changed = true;
<table>
    <tr ng-repeat="car in cars" ng-class="{'changedClass': car.changed}">
        <td>{{ car.name }}</td>
        <td>{{ car.speed }}</td>
        <td>{{ car.length }}</td>
    </tr>
</table>
How to pass int array of color resource ids from array.xml to SwipeRefreshLayout.setColorSchemeResources

How to pass int array of color resource ids from array.xml to SwipeRefreshLayout.setColorSchemeResources


By : user3071764
Date : March 29 2020, 07:55 AM
should help you out I've got Android's SwipeRefreshLayout working and am trying to customize the colors across all the pull to refreshes throughout the app. In order to follow the DRY principle, I've tried moving the desired colors to array.xml as follows: , Turns out I was missing two key pieces.
Wrong Code:
code :
swipeRefreshLayout.setColorSchemeResources(R.array.swipeRefreshColors);
swipeRefreshLayout.setColorSchemeColors(getResources().getIntArray(R.array.swipeRefreshColors));
How pass data from child to parent: Angular Color Picker [(colorPicker)]

How pass data from child to parent: Angular Color Picker [(colorPicker)]


By : sameer chandra Pitta
Date : March 29 2020, 07:55 AM
Any of those help https://github.com/Alberplz/angular2-color-picker , You can use
code :
 <span [(colorPicker)]="arrayColors[selectedColor]" (colorPickerChange)="func($event)"
How to pass json data received from service to an array in component in angular material for angular 4

How to pass json data received from service to an array in component in angular material for angular 4


By : Idayat Oshobajo
Date : March 29 2020, 07:55 AM
will be helpful for those in need I guess you are confused with two different ways to load data in the table. From the looks of your component.service, specifically 'FleetDataService' class, you are trying to get and Observable response. The correct way could be as below, for component.ts:
code :
import { Component, AfterViewInit, ViewChild } from '@angular/core';
import { FleetDataService } from '../../services/fleet-data.service';
import { LoaderService } from '../../services/loader.service';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import {DataSource} from '@angular/cdk/collections';
import { User } from '../../models/fleetData.model';
import {MatPaginator, MatTableDataSource, MatSort} from '@angular/material';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@Component({
   selector: 'app-dashboard',
   templateUrl: './dashboard.component.html',
   styleUrls: ['./dashboard.component.scss']
})

export class DashboardComponent implements AfterViewInit {
  fleetData = null;
  dataSource = new MatTableDataSource(this.fleetData);
  displayedColumns = ['First Name', 'Last Name', 'Score'];

  @ViewChild(MatPaginator) paginator: MatPaginator;
  @ViewChild(MatSort) sort: MatSort;

  applyFilter(filterValue: string) {
    filterValue = filterValue.trim(); // Remove whitespace
    filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults 
    to lowercase matches
    this.dataSource.filter = filterValue;
  }
  constructor(private getFleetData: FleetDataService, private loaderService: 
   LoaderService) { 
   getFleetData.getFleetData().subscribe(
   data => {
    this.fleetData = data;
    this.dataSource.data = this.fleetData;  
   });
   }
   ngAfterViewInit() {
     this.dataSource.paginator = this.paginator;
     this.dataSource.sort = this.sort;
    }
  }
import { Component, AfterViewInit, ViewChild } from '@angular/core';
import { FleetDataService } from '../../services/fleet-data.service';
import { LoaderService } from '../../services/loader.service';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import {DataSource} from '@angular/cdk/collections';
import { User } from '../../models/fleetData.model';
import {MatPaginator, MatTableDataSource, MatSort} from '@angular/material';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
@Component({
   selector: 'app-dashboard',
   templateUrl: './dashboard.component.html',
   styleUrls: ['./dashboard.component.scss']
})

export class DashboardComponent implements AfterViewInit {

  displayedColumns = ['First Name', 'Last Name', 'Score'];
  dataSource = new MatTableDataSource<User>(ELEMENT_DATA);
  @ViewChild(MatPaginator) paginator: MatPaginator;
  @ViewChild(MatSort) sort: MatSort;

  applyFilter(filterValue: string) {
    filterValue = filterValue.trim(); // Remove whitespace
    filterValue = filterValue.toLowerCase(); // MatTableDataSource defaults 
    to lowercase matches
    this.dataSource.filter = filterValue;
  }
  constructor(private getFleetData: FleetDataService, private loaderService: 
   LoaderService) { }
   ngAfterViewInit() {
     this.dataSource.paginator = this.paginator;
     this.dataSource.sort = this.sort;
    }
  }

  const ELEMENT_DATA: User[] = 
  [{
    "FirstName": "Jill",
    "LastName": "Smith",
    "Score": "disqualified"
   }, {
    "FirstName": "Eve",
    "LastName": "Jackson",
    "Score": "94"
   }, {
    "FirstName": "John",
    "LastName": "Doe",
    "Score": "80"
   }, {"FirstName": "Adam",
    "LastName": "Johnson",
    "Score": "67"
   },{
     "FirstName": "Jill",
     "LastName": "Smith",
     "Score": "disqualified"
    }, {
     "FirstName": "Eve",
     "LastName": "Jackson",
     "Score": "94"
    }, {
     "FirstName": "John",
     "LastName": "Doe",
     "Score": "80"
    }, {
    "FirstName": "Adam",
    "LastName": "Johnson",
    "Score": "67"
   },{
    "FirstName": "Jill",
    "LastName": "Smith",
    "Score": "disqualified"
   }, {
    "FirstName": "Eve",
    "LastName": "Jackson",
    "Score": "94"
    }, {
    "FirstName": "John",
    "LastName": "Doe",
    "Score": "80"
   }, {
    "FirstName": ""Adam",
    "LastName": "Johnson",
    "Score": "67"
   },{
    "FirstName": "Jill",
    "LastName": "Smith",
    "Score": "disqualified"
   }, {
    "FirstName": "Eve",
    "LastName": "Jackson",
    "Score": "94"
   }, {
    "FirstName": "John",
    "LastName": "Doe",
    "Score": "80"
   }, {
    "FirstName": "Adam",
    "LastName": "Johnson",
    "Score": "67"
   }];
How pass json array in Angular post method and how get this array in Api?

How pass json array in Angular post method and how get this array in Api?


By : tlanfer
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Solved ..The problem is I have send empty Array reauestData[ ] but now I have changed array to json object
{
code :
prepareData() {


console.log("this.FilterData"+JSON.stringify(this.FilterData)); 
  this.loading = true;
   this.SharedHttpClientService.post(
    this.UrlsService.setAPIURl(
      APIURL.Surveillance_OatsException_Summary),
      this.FilterData)
    .map((response: Response) => {
      this.isLoadingResults = false;
      this.isRateLimitReached = false;
      return response.json();
    })
    .subscribe(Element => {
      this.dataset=Element;
    },
      (err: HttpErrorResponse) => {
        this.isLoadingResults = false;
        this.isRateLimitReached = true;
    });
    this.loading = false;


}
 private attachAuthorization(): RequestOptions {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
//headers.append('HttpHeaders.ACCEPT', 'MediaType.APPLICATION_JSON_VALUE');
headers.append ('Authorization',sessionStorage.getItem('token'));
//console.log(localStorage.getItem('token'));

const options = new RequestOptions({
  headers: headers,
  responseType: ResponseContentType.Json,

});

return options;
  }



public post(url: string, requestData: any):Observable<any>{
const options = this.attachAuthorization();
//console.log(localStorage.getItem('token'));
let Data={"data":requestData}
console.log("Data "+JSON.stringify(Data)); 
return this.http.post(url,JSON.stringify(Data),options);                                                                                                        


 }
   @RequestMapping(value = {"/Oats-Exception-summary/"}, method = RequestMethod.POST)
     public ResponseEntity<List<OatsExceptionSummary>> OatsExceptionSummaryPost(
             @RequestBody Map payload)throws SQLException,JSONException,Exception {
        JSONObject root = new JSONObject( payload);
        JSONArray dataArray = root.getJSONArray("data");
        for (int t=0; t<dataArray.length(); t++) {
            JSONObject JObject = dataArray.getJSONObject(t);
            System.out.println(JObject.getString("columnname"));
        }

        String FilterData="";
        //JSONObject jsonObj=new JSONObject(payload);
        List<OatsExceptionSummary> Data =ISurveillanceService.getOatsExecptionSummary(FilterData);  
         if (Data.isEmpty()) {
                return new ResponseEntity<List<OatsExceptionSummary>>(HttpStatus.NO_CONTENT);
            } else {
                return new ResponseEntity<List<OatsExceptionSummary>>(Data, HttpStatus.OK);
            }
     }
Related Posts Related Posts :
  • Angular 4 Force navigate with refresh
  • Query dom element's properties Angular 4
  • Angular Material Dialog return value
  • Accessing HTTP Error Response Body from HttpInterceptor in Angular
  • Resolve Adal Token for Http Interceptor
  • Is it possible to change namespace name in @nrwl/nx?
  • Angular 4 Router: Getting redirected inside children's first route
  • Uncaught Error: Template parse error There is not such directive with exportAs
  • How can I use @HostListener('window:beforeunload') to call a method?
  • Is it possible to get the type from a generic, given as parameter
  • Ionic 3 - Preventing browser close
  • How to set the color of an icon in Angular Material?
  • how do i handle POST response
  • constructor being called duplicate in *ngFor due to @ViewChild
  • Angular4 OAuth2 IdentityServer4
  • ERROR TypeError: Cannot read property 'name' of undefined
  • Angular4 http get with URL parameter
  • What is the difference between fakeAsync's tick() and done() in angular2 testing?
  • How to push in service without losing previous data?
  • How to make custom arrow mark in agm-map?
  • Upload File in Angular 4 using FormData works in Local but not on Azure App Service
  • How to automatically deploy a Laravel app with embedded Angular to Heroku
  • Unexpected module 'Ng2SmartTableModule' declared by the module 'AppModule'
  • use angular-cli project with visual studio asp.net empty web app?
  • How to load different templates for the same component?
  • Creating Angular4 'Loading' Screen: ExpressionChangedAfterItHasBeenCheckedError
  • Coerce the HttpResponse into an item of the specified type, complete with custom methods
  • Angular/rxjs: Why don't I have to import toPromise anymore?
  • Angular 2 @Input not works for router outlet
  • Nested Model - Angular 2
  • Supress duplicate error in aot compiler
  • Angular2 ExpressionChangedAfterItHasBeenCheckedError
  • Consuming my promise inside my Angular component
  • Despite error cannot read property length of null, the code works
  • Accessing data returned by Promise.all
  • How to add background image with ngStyle?
  • Property X doesn't exist on type Y[]
  • Ionic Headers Failing to set through http.post
  • Angular 4 routing/state problems
  • Angular 2 Dashboard application web api call at initialization
  • ngrx/store:subscribe works fine but async in template gives [object Object]
  • Angular2 - how to mix custom and declared arguments in constructor
  • Implementing Geolocation from @ionic-native/geolocation
  • Angular - Test library before publish
  • AoT Compilation Failed - no such file or directory, lstat 'tsconfig-aot.json'
  • Docker container from Angular4 app : "-p" : executable file not found in $PATH
  • Invalid container name
  • Angular - NgStyle fall back image
  • Angular Observable not updating when I subscribe.
  • Angular mat-checkbox getElementById
  • Angular 4 Injecting route in the APP_INITIALIZER
  • Error: EACCES: Error: EACCES: permission denied, open '/Users/emilio/.ionic/daemon.log' at Error (native)
  • selected value in dropdown list does not work Angular
  • how to smooth scroll down to element on page load angular 4?
  • AngularFire update breaks the app
  • experimentalDecorators Warning on ts lint
  • Dexie - Check if a record exists and initialize it if not present
  • How should I use BehaviorSubject class from a Service in the HTML Template of a Component in Angular 4?
  • How to make ngx-bootstrap datepicker be able to select and display only month and year?
  • What is wrong with this Angular form that makes it reset selected values in the UI unexpectedly?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org