angular2-services

TypeError: Cannot create property '_id' on string '{“[object Object]”:“”}'

本秂侑毒 提交于 2019-12-24 08:47:07
问题 I'm trying to post form data, but I'm getting the following error on submit: TypeError: Cannot create property '_id' on string '{"[object Object]":""}'. My post was successfully captured: Movie {id: "8", firstname: "test", lastname: "test", hero: "test", photo: "xxxxxxxx"} But the data is not saved in MongoDB. I'm using the MEAN stack with Angular2. My server.js : //Need to write the Express code var express = require('express'); var path = require('path'); var bodyParser = require('body

Angular2 cannot use the values of a subscribe in another subscribe (observable)

徘徊边缘 提交于 2019-12-24 07:31:22
问题 I wanted to use a value from a subscribe method in another one, but it gives me undefined because it is not async. Is there a method to use those values together? I want to use this.internships another time in the following subscribe method but it becomes undefined. Thank you for helping! Code: ngOnInit(): void { this._internshipAssignmentService.getInternshipAssignments() .subscribe(internships => { this.internships = internships; <---- value which gives an object this.internshipsHelper =

Can't bind to 'placeholder' since it isn't a known property of 'ng-multiselect-dropdown'

。_饼干妹妹 提交于 2019-12-24 03:03:15
问题 I want to implement autocomplete feature , so an identical option i found was using multi-select drop-down. So i used this module - https://www.npmjs.com/package/ng-multiselect-dropdown But after ditto implementing, i get these errors - Error - ERROR Error: Uncaught (in promise): Error: Template parse errors: Can't bind to 'placeholder' since it isn't a known property of 'ng- multiselect-dropdown'. 1. If 'placeholder' is an Angular directive, then add 'CommonModule' to the '@NgModule.imports'

ngOnChanges not firing when attribute changed by Observable/subscrption

柔情痞子 提交于 2019-12-23 17:38:55
问题 I'm trying to do something after an Observable / subscribe completes. I'm changing an Input property in the subscribe( onNext ) method, but ngOnChanges never fires. What should I be doing differently? import { Component, EventEmitter, OnInit, AfterViewInit, OnChanges, SimpleChanges, Input, Output } from '@angular/core'; @Component({ templateUrl: 'myTemplate.html' , providers: [ NamesService ] }) export class MyPage { @Input() names: any[]; constructor( public namesSvc: NamesService) {}

How to pass params to POST method in angular 2

女生的网名这么多〃 提交于 2019-12-23 16:17:51
问题 I want to Pass parameters to POST method in angular 2 but it is not working whwn I used params:new httpParams().set() but it is not worked .I also tried params:new httpParams().set() and headers then also it is not worked & finally I got the solution with Formdata 回答1: You can use formData to send http params or any kind of attachment. let formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // http request with post method this.httpService.post(

Download a file from asset folder when clicking on a button

浪尽此生 提交于 2019-12-23 13:54:08
问题 I am working on an angular2 project, I have a file in assets folder and I have created a button to download the file while running the app. I see there are quite a many solutions to the above problem so i got confused. Can you please help. <button pButton type="button" (click)="f1()" label="Download Sample Defaults XML File"></button> I need code for f1() which can help me download the file to my Download folder when clicking on above button. Help appreciated. Thanks 回答1: You can either style

Subscribe method don't react to changes [Angular 2]

岁酱吖の 提交于 2019-12-23 10:18:30
问题 I've got the method in my app.component that changes languages in my LangService. When the change occurs the LangService should then response with Observable object to all my other components as I have subscribed to changes in all my components. Unfortunately, it's not happening. It only response to the app.component that called the function for changing the language. I'm not sure where I have made a mistake. Maybe I'm just misunderstanding the whole concept as I'm new to Angular. Here is the

Angular 2 - Exporting Auth Services from AuthModule to AppModule

早过忘川 提交于 2019-12-23 07:40:15
问题 I decided to put LoginComponent, AuthService, LoggedInGuard inside a module called AuthModule: import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { AuthComponent } from './auth.component'; import { LoginComponent } from './components/login/login.component'; import { AuthService } from './services/auth/auth.service'; import { StorageService } from './services/storage/storage.service'; import { RequestService } from './services/request/request

Typescript getter and setter error

旧城冷巷雨未停 提交于 2019-12-23 06:59:03
问题 Ok it's my first day doing some Angular 2 using typescript and I am try to make a simple getter and setter service. import {Injectable} from "angular2/core"; @Injectable() export class TodoService { private _todos:Array = []; get todos():Array { return this._todos; } set todos(value:Array) { this._todos = value; } } Can anyone explain why the Typescript compiler is throwing the following error as I think it should be ok. ERROR in [default] /Users/testguy/WebstormProjects/angular2-seed/src/app

Angular 2/4 How to pass/capture radio button values using Angular typescript

风格不统一 提交于 2019-12-23 05:04:45
问题 I am new to Angular 2/4 and typescript.. I want to get the radio button values selected for the Phone, email and address and pass the selected values to typescript page. client.info.ts How do I go about getting the values of the radio button clicked in typescript from html page. I have included my typescript and html code below. Currently this is not working can someone help here is my code for the client-info.component.html(data pulled from JSOn file) <div class="section-container"> <!--<div