Reload ng-init

(Johan Stigert) #1

I am trying to reload an Item:String that represents an image-url. Currently the Item definition looks like this:

String Img_test2 "[%s]" { http="<[http://127.0.0.1:9090/flickr?year=2018:5000:JSONPATH($.data)]" }

And in custom widget code the following reloads the image as expected every five seconds:

<img width="100%" src="{{itemValue('Img_test2')}}"></img>

What I do not understand is why the following code in custom widget dose NOT reload the image(with or without the added “refresh”):

<div ng-init="model_2018 = {'url': itemValue('Img_test2'), 'refresh': 5}">
      <widget-image ng-model="model_2018" style="margin:auto;"/>
</div>

Any idea why the ng-init dose not reload the displayed image?

0 Likes

(Johan Stigert) #2

Lets try another approach:
Is it possible with AngularJS to regularly request a url in some way?
(Guess that is what the Items are supposed to do but no luck in the first post.)

0 Likes

(Johan Stigert) #3

Ok. Now lets try one last thing:
Is it possible for an item to return html content? For example when defining the item as:

String [item_name] "[%s]" ...

Will print the String “<div>hello</div>” in the habpanel instead of just printing “hello”…
Is this possible in any way?

0 Likes

(Johan Stigert) #4

Ok. I think the answer is that you can not reload images with angular in habpanel. The solution is to deliver the complete html from the item with the following code:

<p ng-bind-html=itemValue('Item_name')></p>
0 Likes