Search Posts

Category: typescript

PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR ReferenceError: Can’t find variable: Map

I have used “MVC ASP.NET Core with Angular” template. I am trying to include phantomJS and run the tests, but i get the following errors: ERROR in [at-loader] ..node_moduleszone.jsdistzone.js.d.ts:122:11 TS2451: Cannot redeclare block-scoped variable ‘Zone’. ERROR in [at-loader] ..node_moduleszone.js distzone.js.d.ts:363:14 TS2300: Duplicate identifier ‘HasTaskState’. ERROR in [at-loader] ..node_moduleszone.js distzone.js.d.ts:372:14 TS2300: Duplicate identifier ‘TaskType’. ERROR in [at-loader] ..node_moduleszone.js distzone.js.d.ts:458:15 TS2451: Cannot redeclare block-scoped variable ‘Zone’. PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR ReferenceError: Can’t find variable: Map […]

Why I only can access data in html, but not in controller (AngularJS, not angular)

I am using angularjs. In my controller, I call a service’s function, then assign return data to a variable (like vm.allTemplatesFromClassificationRepo). But I do not know when I access to vm.allTemplatesFromClassificationRepo in the controller, it is undefined, but when I access to this variable, it has data (not undefined). I do not know if this because of promise issue? I want to find a way that I can get this variable’s value in the controller, […]

return type of method with nested promises

I am getting error from resharper Cannot convert type ‘IPromise < IPromise < void > >’ to type ‘IPromise < void >’: Types of property ‘then’ of types ‘IPromise < void >’ and ‘IPromise < IPromise < void > >’ are incompatible but if I compile the project using tsc from command line I am not getting any error. As I understand the nested promises are being handled by angular and the calling method does […]

Kendo treeview on hover

I am working on Kendo treeview using angular and typescript.Is there any event for onHover in kendo treeview. I want to take the selected element using on hover event. <div kendo-tree-view k-data-source=”treeData” k-data-text-field=”[‘directiveItem.elementId’]” k-expand=”expandtree” k-change=”changetree” k-drag-and-drop=”true k-drop=”onDrop” ng-click=”ctrlOpen($event)”> </div> Source: AngularJS

How to inject service in private constructor

I have an existing code implementing singleton pattern by having private constructor and returning object instance returning the object – export class SingletonFactory { private static factoryInstance = new SingletonFactory(); private constructor() { } public static getInstance() { return SingletonFactory.factoryInstance; } } I need to inject a dependency into this factory. And I changed my code to the following – @Inject(‘MyService’) export class SingletonFactory { private static factoryInstance = new SingletonFactory(); private constructor(private myService : […]

How to access values from fire base in ionic2?

I am working on this ionic app where I access a person’s current location, and get the closest place stored on the app’s fire base based on longitude and latitude. However, I don’t know how to access the longitude and latitude values using typescript of each place stored, in order to compare them. Here is a part of my database: place Cart latitude: 29.8898056 longitude: 31.2294537 name: “Cart” phone: “01000987062” Esma latitude: 29.9442674 longitude: 31.1173287 […]

How can I add dependency to the current class using AngularJs and TypeScript?

Let’s say I have a component class as follows; @Component({ selector: “my”, templateUrl: “/app/my.html” }) export class MyComponent extends MyBase { helper: Helper; constructor() { helper = new Helper(this); } } The Helper class lives in another file like this. export class Helper { constructor(protected component: MyBase) { } } It looks like I can’t use dependency injection for my helper class no matter what since it is storing a reference to the component. The […]

trying to write test cases for each and every line

have written test case for jumping method, but its not going inside onloadend method seat.onloadend, when I see code coverage report. in createSpyObj i called loadend but still its not going inside can you guys tell me how to fix it. providing my code and test case below. I am trying to wite test case for each and every line. jumping(inputValue: any): void { var that = this; var file: File = inputValue.files[0]; var seat: […]

best practice for search data at json object id using map

Let me how to find a json in javascript. Sample Json: { “Employees” : [ { “userId”:”rirani”, “jobTitleName”:”Developer”, “preferredFullName”:”Romin Irani”, “employeeCode”:”E1″, “region”:”CA”, “phoneNumber”:”408-1234567″, “emailAddress”:”romin.k.irani@gmail.com” }, { “userId”:”nirani”, “jobTitleName”:”Developer”, “preferredFullName”:”Neil Irani”, “employeeCode”:”E2″, “region”:”CA”, “phoneNumber”:”408-1111111″, “emailAddress”:”neilrirani@gmail.com” } ] ] } the above json i want find particular userId based on employeeCode,emailAddress ad PhoneNumber. currently i am doing like below for(var i=0; i<json.length;i++){ if((employeeCode==code)&&(emailAddress ==email)&&(PhoneNumber==phone)){ //here i am getting userId } } I want know if this is […]