@JulienB54 wrote:
Hello,
I recently created a new project under Ionic 3. I usually use model with getter and setter, but recently it is impossible to access the methods of the models.
Example :
export class Element { private id:number; public getId():number{return this.id;} public setId(id:number){this.id=id;} }
import { Element } from '../../models/element'; ... private elements:Element[]=new Array<Element>(); ... this.elements.sort(function(a, b){ if(a.getId() < b.getId()) return -1; if(a.getId() > b.getId()) return 1; return 0; });
Error :
ERROR TypeError: a.getId is not a function
at http://localhost:8100/build/12.js:89:23
at Array.sort (native)
at Array.sort (http://localhost:8100/build/polyfills.js:1:9424)
at EditModelPage.webpackJsonp.294.EditModelPage.ionViewDidEnter (http://localhost:8100/build/12.js:88:25)
at ViewController._lifecycle (http://localhost:8100/build/vendor.js:17322:33)
at ViewController._didEnter (http://localhost:8100/build/vendor.js:17222:14)
at NavControllerBase._didEnter (http://localhost:8100/build/vendor.js:43482:18)
at NavControllerBase._transitionFinish (http://localhost:8100/build/vendor.js:43276:22)
at http://localhost:8100/build/vendor.js:43257:26
at t.invoke (http://localhost:8100/build/polyfills.js:3:9283)
Posts: 1
Participants: 1