Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do I change background image of application based on url or routing?
    text
    copied!<p>I would like to change the background image of the application(Html Body) based on the url. And this I want to do in angularJS only :)</p> <p>For eg:</p> <p>1) if user visits the url like this,</p> <p>www.domain.com/<strong>view1</strong></p> <p>Bellow image is shown</p> <p><img src="https://i.stack.imgur.com/DxCZe.gif" alt="enter image description here"></p> <p>2) If user visits url www.domain.com/<strong>view2</strong></p> <p>I want show other image</p> <p><img src="https://i.stack.imgur.com/7lf40.gif" alt="enter image description here"></p> <p><strong>app.js</strong></p> <pre><code> var app = angular.module('app', []); app.config(['$routeProvider', function($routeProvider) { $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'}); $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'}); $routeProvider.otherwise({redirectTo: '/view1'}); }]) app.config(['$locationProvider', function($locationProvider) { $locationProvider.html5Mode(true); }]);; </code></pre> <p><strong>Controler.js</strong></p> <pre><code> app.controller('MyCtrl1',function($scope){ $scope.viewBackground="body" console.log($scope.viewBackground); }) app.controller('MyCtrl2',function($scope){ $scope.viewBackground="profile" }) </code></pre> <p>in the partial html, I am just doing like this</p> <pre><code> &lt;div class="span12"&gt; &lt;p&gt; {{$scope.viewBackground}}zxz &lt;/p&gt; &lt;/div&gt; </code></pre> <p>But some reason I am not able to get the value of <strong>viewBackground</strong> property value.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload