I'm having some troubles with arrays in the ngModel.
Imagine I have a movie databse and I want to search a movie where appears some actors:
$scope.search = {
actors: [1, 2, 3] // actors' ID
};
I'm using $location.search. In order to send an array, I have to "parse" the model and send this:
{ 'actors[]': [1, 2, 3] };
So the url will be: search?actor%5B%5D=1&actor%5B%5D=2&actor%5B%5D=3 (I'm using PHP as backend).
The problem is when I refresh the page with that URL, I'd like to have that inputs loaded, and I have to do the "reverse", so that "actors[]" have to be "actors" because the ngModel key is "actors".
I feel that I'm overcomplicated too much and there is a better way to do this.
Any help would be appreciated.
Thx!
edit:
Plunkr (Url wrong and parsed generated)