angularjs - typescript: problems with angular.bind and map -


i have following code:

  function parsevaluefromcomplextype(complextype, item) {                 return item[complextype];             } 

in order bind value complextype, use angular.bind

let parsevaluefromcomplextypewithvalue = angular.bind('', parsevaluefromcomplextype , config.complextype); val.values = val.values.map(parsevaluefromcomplextypewithvalue); 

now typescript complains:

error ts2345: argument of type 'function' not assignable parameter of type '(value: any, index: number, array: any[]) => {}'.

what error mean , how can rid of it?

the map function accepts function 3 parameters, in structure:

callbackfn: (value: t, index: number, array: t[]) => u 

the bind function of angular returns simple function type:

bind(context: any, fn: function, ...args: any[]): function; 

the error say: can't put function callbackfn: (value: t, index: number, array: t[]) => u expected.

another issue here trying use angular bind in weird way... if want preserve this use arrow function.

maybe (much simpler) this:

var complextype = 'str'; val.values = val.values.map((item, index, array) => item[complextype]); 

Comments

Popular posts from this blog

swift - Button on Table View Cell connected to local function -

dns - Dokku server hosts two sites with TLD's, both domains are landing on only one app -

c# - ajax - How to receive data both html and json from server? -