当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Headers.append方法代码示例

本文整理汇总了TypeScript中@angular/http.Headers.append方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Headers.append方法的具体用法?TypeScript Headers.append怎么用?TypeScript Headers.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@angular/http.Headers的用法示例。


在下文中一共展示了Headers.append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getLastGame

 getLastGame() {
     var headers = new Headers();
     headers.append('Content-Type', 'application/x-www-form-urlencoded');
     var data;
     this.http.post('../IksOks/php/services/get_active_games_service.php', "what=last", { headers: headers })
         .subscribe(
             d => data = d,
             err => {
                 console.log(err._body);
             },
             () => {
                 //console.log(data._body);
                 var game = JSON.parse(data._body);
                 this.newestGameId = game.id;
                 document.getElementById("active-games").style.color = "#B21212";
                 document.getElementById("notification").innerHTML = "Nova igra protiv: " + (this.token == game.player1.id ? game.player2.username : game.player1.username);
                 document.getElementById("notification").style.display = "block";
             }
         );
 }
开发者ID:mrvelibor,项目名称:IksOks,代码行数:20,代码来源:app.component.ts

示例2: fakeAsync

                    fakeAsync(() => {
                        // GIVEN
                        const headers = new Headers();
                        headers.append('link', 'link;link');
                        const user = new User(123);
                        spyOn(service, 'query').and.returnValue(Observable.of({
                            json: [user],
                            headers
                        }));
                        spyOn(service, 'update').and.returnValue(Observable.of({ status: 200 }));

                        // WHEN
                        comp.setActive(user, true);
                        tick(); // simulate async

                        // THEN
                        expect(service.update).toHaveBeenCalledWith(user);
                        expect(service.query).toHaveBeenCalled();
                        expect(comp.users[0]).toEqual(jasmine.objectContaining({id: 123}));
                    })
开发者ID:lbuthman,项目名称:tasks-spring-angular,代码行数:20,代码来源:user-management.component.spec.ts

示例3: addNew

 addNew(usercreds) {
    var headers = new Headers();
       var creds = 'name=' + usercreds.username + '&password=' + usercreds.password;
       var emailid = 'name=' + usercreds.username;
       
       headers.append('Content-Type', 'application/X-www-form-urlencoded');
       
       this.http.post('http://localhost:3333/adduser', creds, {headers: headers}).subscribe((data) => {
           if(data.json().success) {
               this.http.post('http://localhost:3333/sendmail', emailid, {headers: headers}).subscribe((data) => {
           if(data.json().success) {
             console.log('mail sent');
           }
               })
       }
       
           }
       )
       
       
   }
开发者ID:rajayogan,项目名称:angular2-mails,代码行数:21,代码来源:user.service.ts

示例4: updateProfiles

  updateProfiles(id, category, value){

    console.log("You are updating Profile ID: " + id + " with the new value of " + value + " for your " + category + "!");
      
      
    let headers = new Headers();
    headers.append('Content-Type', 'application/json');
      
    var object = {
                    "_id": id,
                    [category]: value
    };
      
      console.log("From Profiles.ts: " + object);

    this.http.put('http://localhost:8080/api/profiles/' + id, JSON.stringify(object), {headers: headers})
      .subscribe(res => {
        console.log(res.json());
      });   

  }
开发者ID:stbyrne,项目名称:athlete,代码行数:21,代码来源:profiles.ts

示例5: login

    public login(requestData: Object = {}): Observable<boolean> | boolean {
        let router: Router = this.router;
        let obs;
        let headers = new Headers();
        headers.append('Content-Type', 'application/json');


        try {
            obs = this.http.post(apiUrl.login,
                JSON.stringify(requestData),
                { headers })
                .map(this.success)
                .catch(this.error);

        } catch (err) {
            obs = Observable.of(false);
        }

        return obs
            .map(this.success);
    }
开发者ID:rafayelrafayel,项目名称:game,代码行数:21,代码来源:AuthenticationSvc.ts

示例6: deletequalification

  deletequalification(applicationid,qualificationid) {
    console.log("Inside delete qualification data function");
    console.log("Application ID : "+applicationid);
    console.log("Experience ID : "+qualificationid);
    let header=new Headers();
      header.append('x-access-token',localStorage.getItem("token"));
      let opts = new RequestOptions({headers:header, params: {_id:applicationid, qualificationid:qualificationid}});

    return new Promise((resolve, reject) => {
      this.http.delete('/privateapi/qualification',opts)
        .map(res => res.json())
        .subscribe(res => {
          console.log('success');
          resolve(res);
        }, (err) => {
          console.log('failure');
          console.log(err);
          reject(err);
        });
    });
  }
开发者ID:patelmitesha,项目名称:OSAR,代码行数:21,代码来源:application.service.ts

示例7: get

	get(url: string, query: any, oauthKey: OAuthKey, oauthToken: OAuthToken){
		let authHeader = new Headers();
		authHeader.append('Authorization',this.oauth.createHeaderString('GET',url,query,oauthKey,oauthToken,this.oauth.createNonce(10),this.oauth.createTimestamp()));

		let requestUrl = url;
		let queryArray:any[] = [];
		Object.keys(query).forEach((k)=>{
			queryArray.push({
				key: this.oauth.fixedEncodeURIComponent(k),
				val: this.oauth.fixedEncodeURIComponent(query[k])
			});
		});
		if(queryArray.length > 0){
			requestUrl += '?';
			requestUrl += queryArray.map((param:any)=>{
				return param.key+'='+param.val;
			}).join('&');
		}

		return this.http.get(requestUrl,{headers: authHeader});
	}
开发者ID:Aoinu,项目名称:ng2-twitter,代码行数:21,代码来源:authorized-request.service.ts

示例8: onSubmit

    onSubmit(value: string): void {
        if(this.userForm.valid) {
          this.postValue = JSON.stringify(value)
          this.postJSON = JSON.parse(this.postValue)
          var body = "username=" + this.postJSON.username + "&password=" + this.postJSON.password;
          var headers = new Headers();

          headers.append('Content-Type', 'application/x-www-form-urlencoded');

          this.http
          .post('http://localhost:3000/api/v1/users/sign_in.json',
            body, {
              headers: headers
            })
          .map(response => response.json())
          .subscribe(
            data => this.res = data
            )
          console.log(this.res)
        }
    }
开发者ID:drews256,项目名称:Ionic2Angular2,代码行数:21,代码来源:login.component.ts

示例9: getListSubjects

  getListSubjects(id){
  	//AGREGAMOS LAS CABECERAS Y PARAMETROS PARA LA CONSULTA
  	let headers= new Headers();
  	headers.append('x-session', window.localStorage.getItem('x-session'));

  	//CREAMOS UNA VARIABLE OBSERVABLE QUE GENERARA LAS NOTIFICACIONES CONSULTANDO EL BACK
  	var observable = Observable.create( observer => {
//  		this.http.get(urlRest + 'admin/course/' +id+ '/topics',{ headers: headers})
      this.http.get(urlRest + 'admin/course/' + id + '/topics',{ headers: headers})
  			.subscribe(dat => {
  				let res = dat.json();
  				observer.next(res);
  				observer.complete();
  				observer.error('Algo esta mal!!');
          console.log('*****************');
          console.log(observable);
          console.log('*****************');
  			})
  	});
  	return observable;
  };
开发者ID:AntonioRABP,项目名称:EAfront,代码行数:21,代码来源:pre-evaluation-service.ts

示例10: onRegister

  onRegister(): void {
    var data = "username=" + this.registerForm.value.username + "&password=" + this.registerForm.value.password + "&firstName=" + this.registerForm.value.firstName + "&lastName=" + this.registerForm.value.lastName;
    var headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    this.http.post('http://localhost/it255-projekat/php/registerservice.php', data, { headers: headers })
      .map(res => res)
      .subscribe(data => this.postResponse = data,
      err => {
        var obj = JSON.parse(err._body);
        document.getElementsByClassName("alert")[0].style.display = "block";
        document.getElementsByClassName("alert")[0].innerHTML = obj.error.split("\\r\\n").join("<br/>").split("\"").join("");
      },
      () => {
        var obj = JSON.parse(this.postResponse._body);
        localStorage.setItem('token', obj.token);
        alert("Uspesno ste napravili nalog")
        this.router.navigate(['./']);
      }
      );

  }
开发者ID:LukaKotur,项目名称:IT255-Projekat,代码行数:21,代码来源:register.component.ts


注:本文中的@angular/http.Headers.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。