为了账号安全,请及时绑定邮箱和手机立即绑定

使用带有角度2的http rest apis

使用带有角度2的http rest apis

MM们 2019-07-27 10:20:07
使用带有角度2的http rest apis所以,我正在通过打字稿在他们的网站上关注角度2指南,并且我陷入了http api集成。我正在尝试创建一个简单的应用程序,可以通过soundcloud api搜索一首歌,但是我很难实现和理解如何开始,而且在线资源以很多不同的方式完成它(我相信快速的角度2语法更改)早些时候)。所以目前我的项目看起来像这样app   components     home       home.component.ts      ...     search       search.component.ts      ...     app.ts    ...   services     soundcloud.ts   bootstrap.ts index.html在示例中没有任何花哨的东西,主要文件将是app.tsimport {Component, View} from 'angular2/core';import {RouteConfig, ROUTER_DIRECTIVES} from 'angular2/router';import {HomeComponent} from './home/home.component';import {SearchComponent} from './search/search.component';@Component({     selector: 'app',     templateUrl: 'app/components/app.html',     directives: [ROUTER_DIRECTIVES]})@RouteConfig([   {path: '/home', name: 'Home', component: HomeComponent, useAsDefault: true},   {path: '/search', name: 'Search', component: SearchComponent}])export class App { }bootstrap.ts    import {App}     from './components/app';import {bootstrap}        from 'angular2/platform/browser';import {ROUTER_PROVIDERS} from 'angular2/router';bootstrap(App, [   ROUTER_PROVIDERS]);我试图找出soundcloud.ts然而我不能和以下方法有错误,即@Inject没有找到(我假设我在这里使用过时的语法)。基本上我想在我的应用程序表单搜索组件中使用soundcloud服务进行api调用。import {Injectable} from 'angular2/core'import {Http} from 'angular2/http'@Injectable()export class SoundcloudService {  http : Http  constructor(@Inject(Http) http) {    this.http = http;  }}soundcloud api不包括在这里,因为我不能先得到基础知识。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 493 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信