Howdie do,
So we have the following controller:
'use strict';
angular.module('24SevenWse')
.controller('NavbarCtrl', ['$scope', 'dataFactory', function ($scope, dataFactory) {
$scope.user = dataFactory.getUser();
$scope.code = dataFactory.getCode();
}
var companyLink = angular.element('<link rel="stylesheet" href="http://localhost/~jw1050/css/$scope.code.css">');
angular.element('head').append(companyLink);
}]);
As you can see, I'm appending a new style sheet to the head element on the page. Now, when I hard code the value such as:
var companyLink = angular.element('<link rel="stylesheet" href="http://localhost/~jw1050/css/ABC.css">');
However, I'm attempting to load a new image via CSS based upon the code the user logs into the software with.
Now, the view that this is for is below:
<nav class="navbar navbar-fixed-top" ng-controller="NavbarCtrl">
<div class="container-fluid">
<div class="navbar-header pull-left">
<a class="navbar-brand tracking-navbar-brand newImage">
<img id="custLogo">
</a>
</div>
</div>
</nav>
The .css file that is being injected into the head just contains the following:
#custLogo {
content: url("http://localhost/~jw1050/logos/logo.png");
}
The .css files will each be named after the code a user can login with. For example, user logs in with the code ABC. That code would correspond directly to the file ABC.css
So I need to pass the code via the controller to the var companyLink so that the style sheet that is appended to the head of the document will be:
<link rel="stylesheet" href="http://localhost/~jw1050/css/ABC.css">
Now I've tried the following in the controller:
var companyLink = angular.element('<link rel="stylesheet" href="http://localhost/~jw1050/css/{{code}}.css">');
var companyLink = angular.element('<link rel="stylesheet" href="http://localhost/~jw1050/css/'{{code}}'.css">');
Neither seem to work. My thinking is the link that I'm appending to the head is part of the view. So it should be able to pass the code in the controller to view, but that doesn't seem to work.
Any ideas?