angular-services

Getting the Selected Object in Select Option in Angular

人走茶凉 提交于 2019-12-01 09:47:28
问题 I have this array of objects which I put on the select option and I would want to select one list of object in the select option. However I can't get the value of that list of object. It outputs [object] [Object]. I want to get that selected list of object of the corporation. I assigned it to the [value] and it gets [object][Object]. <div class="select" > <select class="form-control col-lg-8" #selectedValue (change)="assignCorporationToManage(selectedValue.value)"> <option *ngFor="let

Angular 5 download excel file with post request

跟風遠走 提交于 2019-12-01 01:16:25
问题 I am facing an issue where I have downloaded an Excel file with Angular 1 but if I am implementing the same code in Angular 5 it is showing the error that your file is corrupted. My response is in ArrayBuffer and I am unable to read the file. Below is my code: Service: DownloadData(model:requiredParams):Observable<any>{ const headers = new Headers(); const requestOptions = new RequestOptions({ headers: headers }); requestOptions.headers.append('Content-Type', 'application/json'); const body =

Dynamically add Component in angular 2/4

馋奶兔 提交于 2019-11-30 21:35:56
问题 How can I add component dynamically? toolbar.component.ts: @Component({ selector: 'app-toolbar', template: '<button>Add Text component</button>' }) export class ToolbarComponent { constructor() { } } section.component.ts: @Component({ selector: 'div[app-type=section]', template: '' }) export class SectionComponent { constructor() { } } text.component.ts: @Component({ selector: 'app-text', template: '<p>This is dynamically component</p>' }) export class TextComponent { constructor() { } } view

error TS2339: Property 'catchError' does not exist on type 'Observable<any>'

别来无恙 提交于 2019-11-30 18:47:28
问题 Here is my code in book.service.ts : import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import {Observable} from 'rxjs'; import { Book } from './book'; import { map } from "rxjs/operators"; import { catchError } from 'rxjs/operators'; //import { Component, OnInit } from '@angular/core'; //import {HttpClient} from "@angular/common/http"; //import { Observable } from 'rxjs/Observable'; //import 'rxjs/add/operator/map'; //import 'rxjs/add/operators/catch'

Ascending and Descending Sort in Angular 4

时光总嘲笑我的痴心妄想 提交于 2019-11-30 15:56:50
问题 Why is it that sort function is working : <th (click)="sort('transaction_date')">Transaction Date <i class="fa" [ngClass]="{'fa-sort': column != 'transaction_date', 'fa-sort-asc': (column == 'transaction_date' && isDesc), 'fa-sort-desc': (column == 'transaction_date' && !isDesc) }" aria-hidden="true"> </i></th> WHILE THIS ONE ISN'T WORKING : <th (click)="sort('user.name')">User <i class="fa" [ngClass]="{'fa-sort': column != 'user.name', 'fa-sort-asc': (column == 'user.name' && isDesc), 'fa

Ascending and Descending Sort in Angular 4

允我心安 提交于 2019-11-30 15:17:50
Why is it that sort function is working : <th (click)="sort('transaction_date')">Transaction Date <i class="fa" [ngClass]="{'fa-sort': column != 'transaction_date', 'fa-sort-asc': (column == 'transaction_date' && isDesc), 'fa-sort-desc': (column == 'transaction_date' && !isDesc) }" aria-hidden="true"> </i></th> WHILE THIS ONE ISN'T WORKING : <th (click)="sort('user.name')">User <i class="fa" [ngClass]="{'fa-sort': column != 'user.name', 'fa-sort-asc': (column == 'user.name' && isDesc), 'fa-sort-desc': (column == 'user.name' && !isDesc) }" aria-hidden="true"> </i></th> html <tr *ngFor="let

Send an uploaded image to the server and save it in the server

孤者浪人 提交于 2019-11-30 13:29:28
I want to upload an image and save it in the server. I uploaded the image an got the preview too, but I am stuck in sending that image to the server. I want to send this image to the server using angular services. This is the html code <input type="file" fileread="vm.uploadme" /> <img src="{{vm.uploadme}}" width="100" height="50" alt="Image preview..."> This is the directive (function(){ angular.module('appBuilderApp').directive("fileread", [function () { return { scope: { fileread: "=" }, link: function (scope, element, attributes) { element.bind("change", function (changeEvent) { var reader

Extending a base class in an Angular service

瘦欲@ 提交于 2019-11-30 09:43:54
I have a base class that I would like to extend in a service to help get data in to the angular scope. I have searched around the net for a solution, but have not found one that I like. I have a base class that is used to access the File systems of devices the class structure: var cOfflineStorageBase = Class.extend({ init: function(){ }, CreateFolderDir: function(){ }, DeleteAll: function(){ }, DeleteDirectories: function(){ }, DeleteItem: function(){ }, GetFiles: function(){ }, FileExists: function(){ }, GetPath: function(){ }, GetObject: function(){ }, SaveObject: function(){ }, }); I would

What is the calling order of angularjs functions (config/run/controller)? [duplicate]

我的梦境 提交于 2019-11-30 07:35:02
This question already has an answer here: AngularJS app.run() documentation? 2 answers There are controllers constants directives services factory run config filters functions of angular.js . What is the calling order of all these modules? Learning this I made a fiddle observing the behaviour by console.log . Its like app config app run directive setup directive compile (app controller dependencies) service factory inner factory inner service app controller filter directive linking filter render (w.r.t the markup) Observe yourself here (Check Console). EDIT New Fiddle with filters added 来源:

How to test 'private' functions in an angular service with Karma and Jasmine

淺唱寂寞╮ 提交于 2019-11-30 06:51:20
问题 I have a service in my angular app that looks something like this: angular.module('BracketService', []).factory('BracketService', [function() { function compareByWeight(a, b) { return a.weight - b.weight; } function filterWeightGroup(competitors, lowWeight, highWeight) { //filter stuff } function createBracketsByWeightGroup(weightGroup) { //create some brackets } //set some base line values var SUPER_HEAVY_WEIGHT = 500; var SUPER_LIGHT_WEIGHT = 20; return { //create brackets from a list of