问题
It's a huge title, but it tells about everything, but let me clarify.
I have generator that produces a HTMLstring for an input field (range, checkbox, ...).
This massive string then gets placed in the HTML via $templateCache.put('dynamicSettings, htmlString)
Example of a possible string:
var htmlString = "<input type='range' min='0' max='10' value='5' ng-model='sliderBrightness' ng-change='settingsInputChanged(sliderBrightness, 'sliderBrightness')'>";
When I hardcode this string in my HTML file, it works perfectly. The settingsInputChanged() function gets called and 2 parameters are passed, the value and the unique name. The function then saves the value in the localStorage with the keyvalue (2nd parameter).
But when adding the string dynamically, I get this massive error of which I presume has something to do with the fact that I'm passing a String in the ng-change.
rror: [$parse:syntax] Syntax Error: Token 'undefined' not a primary expression at column null of the expression [settingsInputChanged(sliderBrightness,] starting at [settingsInputChanged(sliderBrightness,].
Or maybe it can't handle that I have 2 '-pairs nested.
Can I change my string to not use those '-pairs to pass my string to the function in the ng-change?
来源:https://stackoverflow.com/questions/28646571/pass-value-and-unique-identifier-to-function-with-ng-change-with-dynamic-content