Peter
Peter

Reputation: 759

EmberJS view components and separate data store

I'm looking at creating a google maps component. But I would like it to be self contained so it will have its own model, controllers and views. So for example the component will fetch its own data from the server and I'll also be able to refresh the data when needed. Ideally I'd simply add the component to the current template that is showing, so for example: {{map-view}} and then everything the component needs to do will take care of its self.

The component will also need to listen to triggered events from other controllers as a user will be able to search for a specific location and the map will need to change its position.

Is this possible to do in EmberJS? As I haven't found anything like this, specially when having its own model. I know there is a component in EmberJS but it seems very limited. Am I wrong in thinking this?

Upvotes: 0

Views: 104

Answers (1)

Rigel
Rigel

Reputation: 882

the controller cannot have its own model all values must be passed to component. Please refer to ember docs and this Discussion

You can make a google map component and pass the location and marker data to the component. this data will get updated due to ember data binding.

so you can have something like this

{{map-view location=userEnteredValue}}

you can search for ember component talk by Kris Selden on youtube which includes a google map component good for you to start with.

updated

https://gist.github.com/krisselden/8189650

Upvotes: 1

Related Questions