草庐IT

typeScript

全部标签

javascript - Angular 6 - 后退按钮按下触发器不止一次

我有以下代码使用Angular6检测后退按钮按下。import{Location}from'@angular/common';exportclassProductsComponentimplementsOnInit{constructor(privatelocation:Location){this.handleBackButtonPress();}handleBackButtonPress(){this.subscribed=true;this.location.subscribe(redirect=>{if(redirect.pop===true){alert('thisisaba

javascript - 使用: and => for the return type with a TypeScript function?有什么区别

我有以下代码:///functionaddThemePrototypes(){vartemplateSetup=newArray();$.fn.addTemplateSetup=function(func,prioritary){if(prioritary){templateSetup.unshift(func);}else{templateSetup.push(func);}};}有人能告诉我为什么要用=>void来声明吗?interfaceJQuery{addTemplateSetup:(func:Function,priority:bool)=>void;}我想我对如何从java

javascript - typescript ,序列化类对象

如何将这些类序列化为JSON?正如您从下面的示例中看到的那样,JSON.stringify()不会序列化Cache_Backend_LocalStorage_TagThree对象中的Cache_Backend_LocalStorage_Tag列表。我错过了什么?interfaceCache_Backend_LocalStorage_Tag_Interface{_tag:string;_keys:string[];}classCache_Backend_LocalStorage_TagimplementsCache_Backend_LocalStorage_Tag_Interface{p

javascript - 在探索 Angular2 之前是否有必要先学习 TypeScript?

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭7年前。Improvethisquestion在尝试学习AngularJS2之前是否有必要先学习TypeScript?

javascript - Aurelia 中的 Typescript 自动注入(inject)

我是Typescript和Aurelia的新手。我正在尝试使@autoinject装饰器在VS2015ASP.NETMVC6项目中工作。这是我的代码import{autoinject}from"aurelia-framework";import{HttpClient}from"aurelia-http-client";@autoinject()exportclassApp{http:HttpClient;constructor(httpClient:HttpClient){this.http=httpClient;}activate(){this.http.get("/api/test

javascript - typescript 编译器错误 TS2307 : Cannot find module 'jquery'

我正在关注JSPM入门guide我想安装jquery包,所以我执行下面的命令。jspm安装jquery但是当我尝试像下面这样用typescript导入它时从“jquery”导入$我从typescript编译器中收到一个错误,提示errorTS2307:Cannotfindmodule'jquery'。不仅对于这个库,对于其他库我也遇到同样的错误。 最佳答案 您需要在编译上下文中包含jquery的类型定义,您可以从https://github.com/DefinitelyTyped/DefinitelyTyped中获取它们

javascript - Angular 2 错误- RC4 版本没有将 "exportAs"设置为 "ngModel"的指令

我在我的应用程序中使用了Angular2表单,并且我已经根据给定的链接创建了表单。https://angular.io/docs/ts/latest/guide/forms.html为了验证和使用表单API,我设置了ngModel值,如#name="id"#id="ngModel"并抛出脚本错误。但如果我将#id="ngModel"设置为#id="ngForm",它就解决了。但就我而言,我必须将模型值设置为ngModel。下面是我的html页面。EmployeeIDEmployeeIDisrequiredEmployeeNameEmployeeIDisrequiredDOJDOJisr

javascript - 如何获取表单输入,使用 Angular Binding 选择值?

我是angular2的新手。所以,请多多包涵。我知道这对某些人来说是个菜鸟问题。ViewBy12345DateFromDateToSearch组件.tsexportclassBalanceComponent{search_data_balance(){//getallinputvalue.}}到目前为止我尝试了什么letvb=balance.viewBy,df=balance.dateFrom,dt=balance.dateTo;//returnserror在angular1中,我们可以使用$scope获取那些值。如有任何帮助,我们将不胜感激。谢谢。 最佳答

javascript - WebStorm 在使用 SystemJS 模块系统时从索引文件导入

假设我有以下源代码结构。/homehome.component.ts/shared/domaincar.domain.tshouse.domain.tsperson.domain.tsindex.ts所有域文件都包含类似exportinterfaceCar{someProperty:number;}索引文件看起来像这样export*from'./car.domain';export*from'./house.domain';export*from'./person.domain';然后在我的主页组件中像这样导入就可以正常工作了。import{Car,Person}from'../sha

javascript - Angular 和 Observable : how to avoid multiple requests to API within a given time

我在Angular4应用程序中有类似的东西(为了示例,我删除了代码)@Injectable()exportclassSomeService{constructor(privatehttp:Http){}get(id:number){returnthis.http.get('http://somedomain/somemodel/${id}.json');}}一些组件使用它来进行API调用。constructor(privatesomeService:SomeService){}...someMethod(){//codehere...this.someService.get(2).su