1

I need to define a local model using ng-init. Unfortunately, I've got an error on the accent. Any idea?

<div ng-init="
    descriptions = {
        floraison: { 
            photos: [
                {file:'1-PaniculeSansPollen',                       description:'Panicule sans pollen'},
                {file:'2-DebutEmissionPollenSurLeBrinPrincipal',    description:'Début émission pollen sur le brin principal'},
                etc. (remaining part of the code has been removed for the question)

The error is as follows:

Error: [$parse:lexerr] Lexer Error: Unexpected next character  at columns 430-430 [é] in expression [descriptions = {
        floraison: { 
            photos: [
                {file:'1-PaniculeSansPollen',                       description:'Panicule sans pollen'},
                {file:'2-DebutEmissionPollenSurLeBrinPrincipal',    description:'Début émission pollen sur le brin principal'},

[edit] Added fiddle: http://jsfiddle.net/stephanedeluca/bS6ZU/

Stéphane de Luca
  • 12,745
  • 9
  • 57
  • 95
  • Why aren't you initializing this variable in a controller ? In most of the cases, it's a [bad practise](https://docs.angularjs.org/api/ng/directive/ngInit) to use ng-init for that ! – Julien Jul 05 '14 at 09:32
  • 1
    Because I am exploring a way to keep my controller lighter than is gonna be at the end of the development. See related question here: http://stackoverflow.com/questions/24577464/multiple-angularness-controllers-in-a-view-and-how-to-load-only-when-necessary @Julien – Stéphane de Luca Jul 05 '14 at 09:35

1 Answers1

0

Hi you just missed few brackets

ng-init=" descriptions = {
        floraison: { 
            photos: [
                       {file:'1-PaniculeSansPollen',  description:'Panicule sans pollen'},
                       {file:'2-DebutEmissionPollenSurLeBrinPrincipal', description:'Début émission pollen sur le brin principal'}
                    ]
                   }
                }"
sylwester
  • 16,498
  • 1
  • 25
  • 33
  • In my actual code, everything is well balanced, it was just an excerpt for the question. The error still is there @sylwester – Stéphane de Luca Jul 05 '14 at 09:25
  • please see there http://jsbin.com/vimero/4/edit in your jsfiddle probably again you missed something – sylwester Jul 05 '14 at 09:55
  • Thanks but I cannot spot what was the problem. I see you transform some tag endings by doubling the slash (what does this mean?), but not all @sylwester – Stéphane de Luca Jul 05 '14 at 10:13
  • @StéphanedeLuca Sorry for delay I wasn't sure about closing tags but they are fine you don't have do 'double close tags'. I don't remember where exactly but in one place was double quotation mark and coma on the end of you object and that makes your object invalid. I hope that will help. if that resolve your problem I'm rally appreciate if you can accept answer. Regards Sylwester – sylwester Jul 05 '14 at 22:24