punkbit
punkbit

Reputation: 7707

angularjs: expression is non-assignable

I'm using ui-gmap-google-map, where I'm defining coordinates on the like:

<div ui-gmap-google-map my-google-maps center='{  latitude: 51.4994961, longitude: -0.1246853 }' zoom="12">

This throws the error:

Expression '{  latitude: 51.4994961, longitude: -0.1246853 }' used with directive 'uiGmapGoogleMap' is non-assignable!

Someone else's reported the same issue and the apparent solution's here https://github.com/angular-ui/angular-google-maps/issues/418, but how to use ng-init to define an object for a scope property that is used to initialise a directive ? From what I know, I have to filter the string to json parse before setting the scope.center ?

Upvotes: 1

Views: 1462

Answers (1)

punkbit
punkbit

Reputation: 7707

Ok, sorry about this I wasn't thinking clearly, but I found how to do it. Here's how:

<div ui-gmap-google-map center='center' ng-init="center = {  latitude: 51.4994961, longitude: -0.1246853 }">

Upvotes: 2

Related Questions