Search Posts

Category: typescript

AngularJs with TypeScript and UI-Router. Accessing parent’s state properties without using parameters

If using Ui-Router with AngularJS and TypeScript, can I access the properties defined in a parent state from the nested estate directly (without using params or data)? I can use $state.$current.parent to access data in the data property, but I would like to access a property defined in the controller directly. I have called it xxx in the sample code provided. Here is my example: THE ROUTES: $stateProvider .state(STATE_NAMES.JOB_ADD.MAIN, { url: ‘/jobs/:Id’, redirectTo: STATE_NAMES.JOBL_ADD.DETAILS, views: […]

AngularJS Directive with Controller Constructor Never Fires

Hi I am trying to write a angularJS directive with a controller in typescript but I can’t seem to get my constructor to fire inside the controller. I have searched the internet extensively but have not been able to find much information as most people are not using typescript with angularJS. The version of angularJS I am using is 1.5.10. Any insight into this issue would be greatly appreciated. class AdvancedFindDirective implements ng.IDirective { public […]

Create function event scroll swipe Typescript

I have the following piece of code that manages when scrolling with the keys up and down the keyboard: KeyEvents() { if (this.subskey != undefined) this.subskey.unsubscribe(); this.subskey = this.APPService.keyEvent$.subscribe((event) => { switch (event.keyCode) { case this.keyCodes.KEY_UP: this.isText(‘UP’); break; case this.keyCodes.KEY_DOWN: this.isText(‘DOWN’); break; } }); } Then with the isText(direction) function and a switch I can do the actions I want as I move down or up. For example when I move down I put an […]

Not able to append data to the FormData

I am trying to upload a file to the server as multipart /form-data. For that, I have created the object of a FormData and append the files and it’s name to it. Unfortunately, the append is not happening and showing nothing as an error. Please help me to resolve this. Following are the codes I’ve tried. HTML <input style=”font-size:15px;” name=”file” type=”file” (change)=”fileChangeEvent($event)” placeholder=”Upload a file…”/> <button [disabled]=”!this.fileCollection.length>0″ type=”button” class=”btn btn-primary btn-s” (click)=”uploadFile()” style=”position:relative; top: 12px;”> […]

How to transition an angularJS application to angular

I currently have a simple search functionality defined in AngularJS (https://next.plnkr.co/edit/qpyvZuvI8vw8q6on?open=lib%2Fscript.js&preview) but I’m hoping to migrate this feature into an existing Angular application. I created a new Angular application and moved the view into app.component.html <head> <script src=”./script.js”></script> </head> <h1> Search Feature </h1> <body ng-app=”search” ng-cloak> <div id=”content” ng-controller=”MainCtrl”> <input type=’text’ ng-model=’searchText’ placeholder=” Enter Query Here ” /> <ul> <li class=”angular-with-newlines” ng-repeat=”course in courses | filter:searchText”> {{course.course_number}}: {{course.title}} <button ng-click=”course.showDesc=!course.showDesc”>See More</button> <div ng-if=”course.showDesc”> Description: {{course.description}} […]

Set type to any from a list of classes

I have large list of components and a function that returns a component from that list based on a search query. The search function looks something like this: export const components = [Comp1, Comp2, Comp3]; export type AnyComponent = Comp1 | Comp2 | Comp3… ; export function findComponent(id: string): Type<AnyComponent>|undefined { return components.find(component => component.id === id); } Is there a way to avoid listing out my components twice both for the type definition and […]

Implementing a script in Ionic Typescript

I would like to implement dynamically added buttons to my Ionic app. I found that I can use the following code for this task. The first part of the code I placed into the home.html file inside html body. <div ng-controller=”MyCtrl”> <div class=”list list-inset”> <div class=”item-input” ng-repeat=”input in inputs”> <label class=”item-input-wrapper”> <input type=”text” placeholder=”Type something” ng-model=”input.value” /> </label> <button class=”button button-small button-balanced” ng-if=”$index == inputs.length – 1″ ng-click=”addInput()”> <i class=”icon ion-plus”></i> </button> <button class=”button button-small […]

Convert Json objects to single array

this is what i am looking for markers: marker[] = [ { lat: 18.533989, lng: 73.825592, }, { lat: 18.540474, lng: 73.837510, label: ‘B’, }, { lat: 18.540972, lng: 73.832146, label: ‘C’ } ] } this is what i have tried for (let i = 0; i < res.length; i++) { // Iterate over numeric indexes from 0 to 5, as everyone expects. let newobj = res[i].destinationAddress.location.coordinates; console.log(newobj); for(let j = 0; j < res.length; […]

I am getting the runtime error when install the prebuild theme in the ionic app

I have created an ionic app using npm as normally and following the readme.txt file to assign the theme in the app I have generated errors:- Error-1 C:/Users/cc/Eklavya1/src/app/app.module.ts import { IonicApp, IonicErrorHandler, IonicModule } from ‘ionic-angular’; import { Camera } from ‘@ionic-native/camera’; import { MyApp } from ‘./app.component’; import { BrowserModule } from ‘@angular/platform-browser’; import { ErrorHandler, NgModule } from ‘@angular/core’; import { IonicApp, IonicErrorHandler, IonicModule } from ‘ionic-angular’; import { Camera } from ‘@ionic-native/camera’; […]

Argument ‘fn’ is not a function, got string. Error while importing services

I am $injecting loginService to the loginController method but it keep throwing [ng:areq] argument ‘fn’ us not a function error. I am using angularjs with typescript here is demo of code what i am doing LoginController.ts -> import { Login, LoginModel } from ‘./login.model’; import { LoginService } from ‘./login.service’; import { IScope } from ‘angular’; export class LoginController { public static $inject : Array<string> = [‘$scope’,’LoginService’]; user = new LoginModel(); constructor($scope : IScope ,private […]

Next Page »