pedroabreu / ion-gallery

Ionic gallery directive
MIT License
124 stars 61 forks source link

Dynamic elements #11

Closed crmolinaz closed 8 years ago

crmolinaz commented 8 years ago

When I tried to add dynamically elements, failed because the library does not support it.

I tried to fix but does not work even using $scope.$apply to reload.

Any idea?

pedroabreu commented 8 years ago

It's possible to add dynamically elements. It was added some versions ago.

Can you reproduce or explain what you're trying to do ?

wish4129 commented 8 years ago

Hello,

I have the same problem when using http.get to assign values to it. The return value for http.get is JSON object. When i directly assign it hardcoded, it works well, just when assign after i get return data from http.get is failed.

The error caught is as shown below TypeError: Cannot read property 'length' of undefined

Thanks & Regards, Kevin M.

pedroabreu commented 8 years ago

Are you using the latest version ? This issue was fixed a couple of versions ago. Can you build an example ? Or send me some sort of code snippet so I can have a look ?

wish4129 commented 8 years ago

imported files

i pull it via bower, should be latest 1?

How i call the API and assign value $http.get("http://www.myapi.com/myapi.aspx") .success(function(response) { $scope.imenu = response; });

The frontend

pedroabreu commented 8 years ago

It should. Just to be sure, check in the package.json if the "version": "0.1.8" if not, update it

wish4129 commented 8 years ago

hello, yeah it is 0.1.8, i wonder what's the problem, the item can be in JSON object format right?

wish4129 commented 8 years ago

can you provide me the code for ionic view example? let me fork it so i can learn from it.

Thank you very much for your time

wish4129 commented 8 years ago

hello,

I think i've made it. I'm able to dynamically set the value in. What changes i've made is simply declare the variable as object before assign it.

Thank you for your time and effort. Kevin Mun

pedroabreu commented 8 years ago

Can you share your solution ? (Just so others can see it if in the future they have the same issue)

wish4129 commented 8 years ago

Hello,

yes of course.

need to declare the variable as object before assign value to it. $scope.imenu = [];

$http.get(http://www.myapi.com/myapi.aspx) .success(function(response) { $scope.imenu = response; });

Thanks & Regards, Kevin Mun

pedroabreu commented 8 years ago

Makes sense. Was passing an undefined scope variable to the directive. Thanks