javascript - CSS file is not being loaded dynamically via ng-href -


i trying dynamically load different css styles page using ng-href, page not being updated activated style. code follows:

<html ng-app="myapp" ng-controller="mycontroller myctrl">     <head>         <link rel="stylesheet" ng-href="../assets/css/{{ myctrl.style }}.css">     </head> </html> 

in controller, following:

vm.style = "redstyle"; pub.subscribe('style', function(thestyle) {     vm.style = thestyle; }); 

the variable in subscribe updated new style once publish has taken place. respective css file not being loaded such style updated on page. ideas missing out on?

here working demo

it's same have it's else in code. hard tell unless put code.

assuming stylesheet exist, , style variable getting updated guess culprit

pub.subscribe() 

if callback being triggered outside of angular angular wont see updated variable. can bring angular space so:

pub.subscribe('style', function (thestyle) {   $scope.$apply(function(){       vm.style= thestyle;    });                }); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -