當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Http.put方法代碼示例

本文整理匯總了TypeScript中angular2/http.Http.put方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Http.put方法的具體用法?TypeScript Http.put怎麽用?TypeScript Http.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2/http.Http的用法示例。


在下文中一共展示了Http.put方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: saveStory

    saveStory(userId, story:Story):Observable<Story> {
        let headers = new Headers({
            'Content-Type': 'application/x-www-form-urlencoded'
        });

        let options = new RequestOptions({
            headers: headers
        });
        story.userId = userId;

        if (!!story._id) {
            story.createdAt = story.createdAt || (new Date());
            story.lastModifiedAt = (new Date());
            return this.http.put(this.configuration.apiBasePath + '/story/' + userId + '/'+ story._id , "data=" + JSON.stringify(story), options)
                .map(res => res.json())
                .catch(this.logger.errorCatcher());
        }
        else {
            story.createdAt = (new Date());
            story.lastModifiedAt = (new Date());
            return this.http.post(this.configuration.apiBasePath + '/story/' + userId + '/', "data=" + JSON.stringify(story), options)
                .map(res => res.json())
                .catch(this.logger.errorCatcher());
        }
    }
開發者ID:FrancescoFontana,項目名稱:chronostories,代碼行數:25,代碼來源:story.service.ts

示例2: getUseRestriction

 getUseRestriction(questions: string): Observable<Response> {
     let headers = new Headers();
     headers.append('Content-Type', 'application/json');
     return this.http.put(AppSettings.DAR_USERESTRICTION_ENDPOINT, questions, {
         headers: headers
     });
 }
開發者ID:dags,項目名稱:match-tool,代碼行數:7,代碼來源:dar.service.ts

示例3: update

	update(form: Form) {
		return this._http.put(
			Config.api('form/'+form.id),
			JSON.stringify(form),
			this.headers()
		);	
	}
開發者ID:myste1tainn,項目名稱:any.form-php,代碼行數:7,代碼來源:form.service.ts

示例4: saveSelectionForComp

 saveSelectionForComp(compId:String, selection:Selection):Observable<Response> {
     // /auth/ URLs are protected by the middleware
     return this._http.put(BASE_URL + '/auth/competition/selection/push/' + compId, JSON.stringify(selection), {
             headers: json()
         })
         .share();
 }
開發者ID:jamesmorgan,項目名稱:ng2-picks,代碼行數:7,代碼來源:CompetitionApi.ts

示例5: updatePerson

    updatePerson(data: string, http: Http) {
        var config = new Config();
        let headers = new Headers({ 'Content-Type': 'application/json' });
        var options = new RequestOptions({ headers: headers });

        return http.put(config.apiBaseUrl + "People", data, options).toPromise();
    };
開發者ID:mberaz,項目名稱:angular2-EF-core,代碼行數:7,代碼來源:people.service.ts

示例6: saveBlog

 saveBlog(blog: BlogEntry): Observable<Response> {
     if (blog.id) {
         return this.http.put('/api/blogs/' + blog.id, blog.json(), this.opts);
     } else {
         return this.http.post('/api/blogs', blog.json(), this.opts);
     }
 }
開發者ID:liuyijie,項目名稱:angular2-webpack-demo-routing-and-http,代碼行數:7,代碼來源:blog-service.ts

示例7: createRequest

 private createRequest(type: string,data ?: Object) : Observable<any> {
   let _url : string = this.buildUrl(data);
   let _request : Observable<any>
   let stringParam : string = '';
   let _jsonBuild : any = {}
   if(_url.split('?')[1] && _url.split('?')[1].length) {
     (_url.split('?')[1].split('&')).forEach( _paramPart => {
       _jsonBuild[_paramPart.split('=')[0]] = _paramPart.split('=')[1]; 
     });
     stringParam = JSON.stringify(_jsonBuild);
   }
   switch (type) {
     case "post":
       _request = this._http.post(_url.split('?')[0], stringParam);
       break;
     case "patch":
       _request = this._http.patch(_url.split('?')[0], stringParam);
       break;
     case "put":
       _request = this._http.put(_url.split('?')[0], stringParam);
       break;
     case "delete":
       _request = this._http.delete(_url);
       break;
     case "head":
       _request = this._http.head(_url);
       break;
     default:
       _request = this._http.get(_url);
       break;
   }
   this._request = _request.map((response: Response) => response.json());
   return this._request;
 }
開發者ID:iloveyo123u1,項目名稱:ng2-resource,代碼行數:34,代碼來源:index.ts

示例8: updateGame

 updateGame(game: Game) {
     this.http.put(`${BASE_URL}/${game.id}`, JSON.stringify(game), HEADER)
         .subscribe(
             action => this.store.dispatch({ type: 'UPDATE_GAME', payload: game }),
             error => console.log('Error: ' + error)
         );
 }
開發者ID:elqsar,項目名稱:angular2-simple-starter,代碼行數:7,代碼來源:game.service.ts

示例9: update

 update(band: Band) {
     return this._http.put(this.baseAPIUrl + 'band/' + band.id + '/', JSON.stringify({
         name: band.name,
         description: band.description
     }), this.getHeaders())
         .map(res => res.json())
 }
開發者ID:YetAnotherTeam,項目名稱:jatumba-frontend,代碼行數:7,代碼來源:band.service.ts

示例10: addContenido

 //AĂąadir contenido al usuario
 addContenido(producto: Prod, usuario: Usuario){
   usuario.coleccion.push(producto);
   if(producto.tipoprod == 3){
     usuario.nPelis = usuario.nPelis + 1;
   }
   if(producto.tipoprod == 2){
     usuario.nSeries = usuario.nSeries + 1;
   }
   if(producto.tipoprod == 1){
     usuario.nJuegos = usuario.nJuegos + 1;
   }
   let cambio = JSON.stringify(usuario);
   let headers = new Headers({
     'Content-Type': 'application/json',
     'X-Requested-With': 'XMLHttpRequest'
   });
   let options = new RequestOptions({headers});
   return this.http.put(BASE_URL + usuario.id, cambio, options)
   .map(
     response => response.json()
   )
   .catch(
     error => this.handleError(error)
   );
 }
開發者ID:Alvaro95pa,項目名稱:daw_web,代碼行數:26,代碼來源:usuario.service.ts


注:本文中的angular2/http.Http.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。