Posts

javascript - Angular: How to show icon.png depending on the attribute of a item? -

i have array of objects looks this: [{"name":"steve", "hourly_wage":16, "status":"part-time"}, {"name":"maria", "hourly_wage":25, "status":"full-time"}, {"name":"jose", "hourly_wage":21, "status":"former"}] i want display icon each person's employment status. full circle full time, half circle part time , empty circle former. how can go doing in javascript/angular? i'm thinking if statement of sort inside ng-hide? most generic way in opinion create mapping, use it. js: $scope.statusiconmapping = {"part-time": "half_circle.jpg", "full-time": "full_circle.jpg", "former": "empty_circle.jpg" }; markup: <div ng-repeat="employee in employees"> ... <img src="{{statusiconmapping[employee.status]}}" /> <...

angular - angular2 observable scan once then subscribe by many async -

i need bind shared observable 2 times in different moments. second binding gets null when evaluated first time until next item appears. here component class: export class app { subject = new behaviorsubject(1); scan = this.subject.scan((current, change) => current + change, 0).share(); other = this.scan.map(item => item); } and here template: <div> <button (click)="clickedscan=true">show scan</button> <button (click)="clickedother=true">show other</button> <button (click)="subject.next(1)">next</button> <div *ngif="clickedother"> other | async: <b>{{ '' + (other | async) }}</b> </div> <div *ngif="clickedscan"> scan | async: <b>{{ '' + (scan | async) }}</b> </div> </div> and here plunker ( update : plunker updated accepted answer) share() needed since otherwise scan method b...

android - How to know data usage of mobile for specific sim slot -

i trying find data usage specific sim slot. using trafficstats.getmobilerxbytes() method gives total usage of both sim in dual sim device. want particular data usage of individual sim. suggestions appreciated. just hint: upon sim slot data active event trafficstats.setthreadstatstag(identifier_tag); and if(trafficstats.getthreadstatstag() == sim1_slot){ int usedbytes = trafficstats.getmobilerxbytes() }else{ // sim2 slot int usedbytes = trafficstats.getmobilerxbytes() }

android split string doesn't work correctly -

this question has answer here: android split not working correctly 2 answers in android app, split array value array. i have array name arraya. log of arraya[0]: peter|mustermann now split peter , mustermann, try this: string [] arrayb = arraya[0].split("|"); but log of arrayb[0] , arrayb[1] not be: peter and mustermann it be: p and nothing any ideas ? :( just use single quote string [] arrayb = arraya[0].split('|');

kendo ui grid date sorting is not working -

i trying sort data on desc date order can't, keep getting asc ordering on kendo ui grid, here code. this.gridconfig = { datasource: { transport: { read: '/api/endpoint, datatype: 'json' }, schema: { data: "my_data_var" } }, sort: { field: "date", dir: "desc"}, resizable: true, filterable: true, pageable: { pagesize: 200 }, columns: [{ field: 'date', title: 'date', template: "#= kendo.tostring(kendo.parsedate(date, 'yyyy-mm-dd'), 'dd/mmm/yyyy') #" sort option datasource configuration should : datasource: { transport: { read: '/api/endpoint, datatype: 'json' }, schema: { data: "my_data_var" ...

android - Ionic: Adding platform gives error -

having first ionic encounter, setting environment android app on osx yosemite. running command sudo ionic platform android getting following error: error: %s error: enoent, no such file or directory '/users/myuser/hooks' @ error (native) @ object.fs.readdirsync (fs.js:761:18) @ object.sethookspermission (/usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/lib/hooks.js:116:24) @ object.ionictask.run (/usr/local/lib/node_modules/ionic/lib/ionic/cordova.js:51:13) @ object.run (/usr/local/lib/node_modules/ionic/lib/cli.js:95:32) @ object.<anonymous> (/usr/local/lib/node_modules/ionic/bin/ionic:9:10) @ module._compile (module.js:460:26) @ object.module._extensions..js (module.js:478:10) @ module.load (module.js:355:32) @ function.module._load (module.js:310:12) updated hooks directory have execute permissions error happened { [error: enoent, open '/users/myuser/config.xml'] errno: -2, code: 'enoent', path:...

lambda - Event is not Called C# -

i'm making nfc library, need raise event, when card has been read. in mainproject call library this: reader = new nfcreader(); if (reader.initialize()) { reader.uidreceived += (s, args) => displaytext(string.format("uid received: {0}", args.uid)); } my library: public class nfcreader { private scardmonitor monitor; public event eventhandler<nfcreadereventargs> uidreceived; public bool initialize() { // when card inserted, event raised // want read uid of card monitor = new scardmonitor(new scardcontext(), scardscope.system); monitor.cardinserted += (s,a) => getuid(a.readername); return true; } private void getuid(string readername) { string uid = myuidgetter(readername); onuidreceived(uid); } private void onuidreceived(string uid) { var handler = uidreceived; if (handler == null) { ...