0

I using visjs, i want to hide the first image of the first div, how i can do that, i used ng-show but it doesnt work??

storyboard.drawTimeLine = function (start, end, color, marg,km) {
        var elm = angular.element(document.querySelector('#vv'));
            elm.html("");
            item = {};
            item.id = start + '@' + end;
            item.start = start;
            item.end = end;
            item.title = elm.append($compile(
                '<div style="padding-left:0px;padding-bottom: 9px "><img src="../../../../assets/img/fuel.png"> -</div>'+
                '<div style="padding-left:0px;padding-bottom: 9px "><img src="../../../../assets/img/oil.png">  -</div>')($scope)).html();
                ;
            item.style ="top:"+ marg +"px;height:14px;background-color:" + color + ";border-color:" + color;
        };

2 Answers2

0

You probably shouldn't be building your HTML like that.

You should use AngularJS properly to bind your HTML to your controller.

About hiding: <div ng-hide="myValue"></div>

Checkout more: https://docs.angularjs.org/api/ng/directive/ngHide

ricardofagodoy
  • 146
  • 1
  • 10
0

Your problem is that you are injecting HTML. In angular; HTML shall not be included into Javascripts but in templates.

However; if you want that your generated HTML to be interpreted as an Angular code (and add ng-hide); you shall "compile" it that is a complicated process (not for beginner)

https://docs.angularjs.org/guide/compiler

For an example; please have a look at that post : https://stackoverflow.com/a/11780658/3687474

aorfevre
  • 5,034
  • 3
  • 21
  • 51