Search Posts

Category: json

Each key must be a number of string; got undefined protractor

I am trying to read data from json file but I have some trouble. How can I get items from a json file to individual items? My json file: [ { “UserName”: “test@test.en”, “Password”: “tests123” } ] My method: element(by.name(‘username’)).sendKeys(browser.params.UserName); element(by.name(‘password’)).sendKeys(browser.params.Password); as a result i get Failed: each key must be a number of string; got undefined Source: AngularJS

Populate dynamic dropdown in angularjs from json data

<div class=”col-md-6 col-lg-6 form-group form-md-line-input has-info form-md-line-input form-md-floating-label has-info”> <label class=”control-label”>Designation</label> <select class=”form-control edited” id=”form_control_1″ name=”desgn_typ” ng-model=”details.desgn_typ” ng-options=”types.id as types.name for types in type_1″ id=”desgn_typ”> <!– <option>HR Executive</option> <option>Manager</option> <option>Employee</option> <option>Admin</option> –> </select> </div> How to populate dynamic dropdown in angularjs from json data Source: AngularJS

Read data from json

This is my JSON file { “styleMapping”: { “1”: { “zIndex”: 1, “StyleMappingCollection”: { “636404903145791477”: { “border”: { “color”: “#FF000000”, “width”: “Small”, “type”: “Solid” }, “background”: { “bgOption”: “Image”, “thumbOption”: “Pointer”, “opacity”: 1.0, “bgColor”: “#FFF5F5DC”, “bgImage”: “C:UsersrajDownloadsimagesimage.jpg”, } } } i want to capture bgImage parameter in my javascript. My script code is $http.get(‘Data//xyz.json’).then(successCallback, errorCallback); function successCallback(response) { sliderCtrlPtr.sliderParams = response.data; sliderCtrlPtr.sliderParams.height = response.data.deviceHeight; console.log(“After JSON read : “,sliderCtrlPtr.sliderParams); } function errorCallback(error) { //error code […]

Unable to render navigation menu in angular 1 using nested json data

I want to implement a navigation bar using json data which is fetched by angular service. I ave my service and controller working great, but I am unable to render the nested json data into my view. Below is my json data: { “menu”: [ { “name”: “Electronics”, “link”: “1”, “sub”: [ { “name”: “Mobiles”, “link”: “1.1”, “sub”: [ { “name”: “Samsung”, “link”: “1.1.1”, “sub”: null }, { “name”: “Apple”, “link”: “1.1.2”, “sub”: null }, […]

I am trying to fetch details of patient from a url containing json data using get method of angular js2

My classes are: ****Patient Service class.ts**** @Injectable() export class PatientService{ url=”http://localhost:8080/rest/patientC”; constructor(private http:Http){} getPatientWithObservale():Observable<patient[]>{ return this.http.get(this.url) .map(this.extractdata) .catch(this.handleErrorObservable); } private extractdata(res:Response){ let body=res.json(); console.log(body.data); return body.data || {}; } } **Observable Component class.ts** export class ObservableComponent implements OnInit{ patients:patient[]; errorMessage: string; patientName: string; patient=new patient(); constructor(private patientService: PatientService){} ngOnInit(){ this.fetchPatient(); } fetchPatient():void{ this.patientService.getPatientWithObservale() .subscribe(patients=>this.patients = patients, error=>this.errorMessage=error); } } **Observable component.html** <h3>Patient Details with Observable </h3> <table> <tr> <th>Id</th> <th>First Name</th> <th>Last Name</th> <th>Age</th> <th>Gender</th> […]

type in input fields in text

// Load the Google Transliterate API google.load(“elements”, “1”, { packages: “transliteration” }); function onLoad() { var options = { sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH, destinationLanguage: [google.elements.transliteration.LanguageCode.MARATHI], shortcutKey: ‘ctrl+g’, transliterationEnabled: true }; // Create an instance on TransliterationControl with the required // options. var control = new google.elements.transliteration.TransliterationControl(options); // control.makeTransliteratable([‘firstName’]); control.makeTransliteratable([‘userName’, ‘firstName’]); } google.setOnLoadCallback(onLoad); <script src=”https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js”></script> <script type=”text/javascript” src=”https://www.google.com/jsapi”> </script> <div class=”input-group mb-1 row loginInput”> <span class=”input-group-addon”><i class=”icon-email”>@</i></span> <input type=”text” class=”form-control” id=”userName” placeholder=”{{ ‘Login.E-mail ID / Mobile’ | translate […]

ng repeat json parse show empty string

I had the array of objects string from a list of array. I convert object string to object using method of JSON.parse the object but it shows empty within ng-repeat. Jade .item.col-md-4(ng-repeat=’p in searchData | filter: paginate | orderBy: sortKey ‘) // `p` is a object of string, for example “{id:2, name:’abel’}”; – var property = JSON.parse(“{{ p }}”); // Error at this line +AddPropertyCard(property) Error var property = JSON.parse(“”); Unexpected token { in JSON […]

AngularJS ng-repeat is not iterating through my JSON

I have build an API to get response from MongoDB, which is giving me response in form of JSON data. I have tried many solution to iterate the loop over JSON data with the help of ng-repeat but it didn’t work for me. Here the the HTML, JS code of mine..and the response which i got from server. Thankyou HTML <div ng-controller=”afterLoginController” > <button ng-click=”view()” ng-show=”view_buttons”> View Attendance </button> <button ng-click=”fill()” ng-show=”view_buttons”> Fill Attendance </button> […]

Formating dates in AngularJS ng-repeat directive from json array

I’m obtaining a response in json format from laravel application like below: [{“id”:11,”name”:”test”,”description”:”adddas”,”isDone”:false,”created_at”:{“date”:”2017-09-06 12:23:23.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:12,”name”:”test2″,”description”:”asdasdsa”,”isDone”:false,”created_at”:{“date”:”2017-09-13 06:23:22.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:13,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 18:44:57.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:14,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 20:23:58.000000″,”timezone_type”:3,”timezone”:”UTC”}},{“id”:15,”name”:”task12321″,”description”:”jakis tam testowy task”,”isDone”:false,”created_at”:{“date”:”2017-09-03 20:45:35.000000″,”timezone_type”:3,”timezone”:”UTC”}}] I’m trying to format these data in Angular js in ng-repeat directive in way like below: <div class=”table-responsive”> <table class=”table table-hover”> <thead> <tr> <th>name</th> <th>Created at</th> </tr> </thead> <tbody> <tr ng-repeat=”task in tasks”> <td>{{task.name}}</td> <td>{{ task.created_at.date | date:’yyyy-MM-dd HH:mm:ss’ }}</td> </tr> </tbody> </table> </div> The problem is with […]

How do I read a JSON file in Angular?

I am trying to load a JSON file from local disk and use the data from it to fill a FabricJS canvas. I have problems on getting the data from the file. This is what i have till now. app.html <input type=”file” accept=”.json” id=”fileInput” (change)=”loadFile($event)”/> app.ts loadFile(event) { const eventObj: MSInputMethodContext = <MSInputMethodContext> event; const target: HTMLInputElement = <HTMLInputElement> eventObj.target; const files: FileList = target.files; this.file = files[0]; const reader = new FileReader(); reader.readAsText(this.file, ‘utf8’); […]

Next Page »