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

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -