set up an ng-src from within routeprovider to display image elsewhere











up vote
0
down vote

favorite












firstly i have my ng-route setup nicely and ng-view behaving well.
what i want is to have a header image that will change when the nav menu is selected and have the view change lower one the page with ng-view.



code posted below is partial of work but pretty detailed. i'm hoping that someone with a keen eye can pic my issue straight away.



I need the div with img ng-src to show an image based on the route controller for each menu option.



If this isn't possible is there another way??






var app = angular.module('myApp', ['ngRoute']);

app.config(function($routeProvider) {
$routeProvider

.when('/', {
templateUrl : 'home.html',
controller : 'HomeController'
})

.when('/book', {
templateUrl : 'book.html',
controller : 'BookController'
})

.when('/sails', {
templateUrl : 'sails.html',
controller : 'SailsController'
})

.when('/contact', {
templateUrl : 'contact.html',
controller : 'ContactController'
})

.otherwise({redirectTo: '/'});
});

app.controller('HomeController', function($scope) {

var image = {
image: "img/img/seagate photo shoot--19.jpg"
};

$scope.image = image;
});

<div class="container">
<a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/book">Book Now</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/sails">Dining</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/contact">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
<img src="img/flogo.png" width="25px" alt="facebook" align="middle">
</a>
<a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
<img src="img/flogo.png" width="25px" alt="facebook" align="middle">
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
<img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
</a>
</li>
</ul>
</div>
</div>
</nav>

<header>
<div class="headerimg">
<img ng-src="{{image.image}}" alt="">
</div>
</header>

<section class="py-5">
<div class="container">
<div ng-view></div>
</div>
</section>





Any help would be appreciated










share|improve this question


























    up vote
    0
    down vote

    favorite












    firstly i have my ng-route setup nicely and ng-view behaving well.
    what i want is to have a header image that will change when the nav menu is selected and have the view change lower one the page with ng-view.



    code posted below is partial of work but pretty detailed. i'm hoping that someone with a keen eye can pic my issue straight away.



    I need the div with img ng-src to show an image based on the route controller for each menu option.



    If this isn't possible is there another way??






    var app = angular.module('myApp', ['ngRoute']);

    app.config(function($routeProvider) {
    $routeProvider

    .when('/', {
    templateUrl : 'home.html',
    controller : 'HomeController'
    })

    .when('/book', {
    templateUrl : 'book.html',
    controller : 'BookController'
    })

    .when('/sails', {
    templateUrl : 'sails.html',
    controller : 'SailsController'
    })

    .when('/contact', {
    templateUrl : 'contact.html',
    controller : 'ContactController'
    })

    .otherwise({redirectTo: '/'});
    });

    app.controller('HomeController', function($scope) {

    var image = {
    image: "img/img/seagate photo shoot--19.jpg"
    };

    $scope.image = image;
    });

    <div class="container">
    <a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
    <ul class="navbar-nav ml-auto">
    <li class="nav-item active">
    <a class="nav-link" href="#/">Home</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#/book">Book Now</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#/sails">Dining</a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="#/contact">Contact</a>
    </li>
    <li class="nav-item">
    <a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
    <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
    </a>
    <a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
    <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
    </a>
    </li>
    <li class="nav-item">
    <a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
    <img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
    </a>
    </li>
    </ul>
    </div>
    </div>
    </nav>

    <header>
    <div class="headerimg">
    <img ng-src="{{image.image}}" alt="">
    </div>
    </header>

    <section class="py-5">
    <div class="container">
    <div ng-view></div>
    </div>
    </section>





    Any help would be appreciated










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      firstly i have my ng-route setup nicely and ng-view behaving well.
      what i want is to have a header image that will change when the nav menu is selected and have the view change lower one the page with ng-view.



      code posted below is partial of work but pretty detailed. i'm hoping that someone with a keen eye can pic my issue straight away.



      I need the div with img ng-src to show an image based on the route controller for each menu option.



      If this isn't possible is there another way??






      var app = angular.module('myApp', ['ngRoute']);

      app.config(function($routeProvider) {
      $routeProvider

      .when('/', {
      templateUrl : 'home.html',
      controller : 'HomeController'
      })

      .when('/book', {
      templateUrl : 'book.html',
      controller : 'BookController'
      })

      .when('/sails', {
      templateUrl : 'sails.html',
      controller : 'SailsController'
      })

      .when('/contact', {
      templateUrl : 'contact.html',
      controller : 'ContactController'
      })

      .otherwise({redirectTo: '/'});
      });

      app.controller('HomeController', function($scope) {

      var image = {
      image: "img/img/seagate photo shoot--19.jpg"
      };

      $scope.image = image;
      });

      <div class="container">
      <a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#/">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/book">Book Now</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/sails">Dining</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/contact">Contact</a>
      </li>
      <li class="nav-item">
      <a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      <a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
      <img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
      </a>
      </li>
      </ul>
      </div>
      </div>
      </nav>

      <header>
      <div class="headerimg">
      <img ng-src="{{image.image}}" alt="">
      </div>
      </header>

      <section class="py-5">
      <div class="container">
      <div ng-view></div>
      </div>
      </section>





      Any help would be appreciated










      share|improve this question













      firstly i have my ng-route setup nicely and ng-view behaving well.
      what i want is to have a header image that will change when the nav menu is selected and have the view change lower one the page with ng-view.



      code posted below is partial of work but pretty detailed. i'm hoping that someone with a keen eye can pic my issue straight away.



      I need the div with img ng-src to show an image based on the route controller for each menu option.



      If this isn't possible is there another way??






      var app = angular.module('myApp', ['ngRoute']);

      app.config(function($routeProvider) {
      $routeProvider

      .when('/', {
      templateUrl : 'home.html',
      controller : 'HomeController'
      })

      .when('/book', {
      templateUrl : 'book.html',
      controller : 'BookController'
      })

      .when('/sails', {
      templateUrl : 'sails.html',
      controller : 'SailsController'
      })

      .when('/contact', {
      templateUrl : 'contact.html',
      controller : 'ContactController'
      })

      .otherwise({redirectTo: '/'});
      });

      app.controller('HomeController', function($scope) {

      var image = {
      image: "img/img/seagate photo shoot--19.jpg"
      };

      $scope.image = image;
      });

      <div class="container">
      <a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#/">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/book">Book Now</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/sails">Dining</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/contact">Contact</a>
      </li>
      <li class="nav-item">
      <a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      <a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
      <img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
      </a>
      </li>
      </ul>
      </div>
      </div>
      </nav>

      <header>
      <div class="headerimg">
      <img ng-src="{{image.image}}" alt="">
      </div>
      </header>

      <section class="py-5">
      <div class="container">
      <div ng-view></div>
      </div>
      </section>





      Any help would be appreciated






      var app = angular.module('myApp', ['ngRoute']);

      app.config(function($routeProvider) {
      $routeProvider

      .when('/', {
      templateUrl : 'home.html',
      controller : 'HomeController'
      })

      .when('/book', {
      templateUrl : 'book.html',
      controller : 'BookController'
      })

      .when('/sails', {
      templateUrl : 'sails.html',
      controller : 'SailsController'
      })

      .when('/contact', {
      templateUrl : 'contact.html',
      controller : 'ContactController'
      })

      .otherwise({redirectTo: '/'});
      });

      app.controller('HomeController', function($scope) {

      var image = {
      image: "img/img/seagate photo shoot--19.jpg"
      };

      $scope.image = image;
      });

      <div class="container">
      <a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#/">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/book">Book Now</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/sails">Dining</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/contact">Contact</a>
      </li>
      <li class="nav-item">
      <a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      <a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
      <img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
      </a>
      </li>
      </ul>
      </div>
      </div>
      </nav>

      <header>
      <div class="headerimg">
      <img ng-src="{{image.image}}" alt="">
      </div>
      </header>

      <section class="py-5">
      <div class="container">
      <div ng-view></div>
      </div>
      </section>





      var app = angular.module('myApp', ['ngRoute']);

      app.config(function($routeProvider) {
      $routeProvider

      .when('/', {
      templateUrl : 'home.html',
      controller : 'HomeController'
      })

      .when('/book', {
      templateUrl : 'book.html',
      controller : 'BookController'
      })

      .when('/sails', {
      templateUrl : 'sails.html',
      controller : 'SailsController'
      })

      .when('/contact', {
      templateUrl : 'contact.html',
      controller : 'ContactController'
      })

      .otherwise({redirectTo: '/'});
      });

      app.controller('HomeController', function($scope) {

      var image = {
      image: "img/img/seagate photo shoot--19.jpg"
      };

      $scope.image = image;
      });

      <div class="container">
      <a class="navbar-brand" href="#"><img src="img/Seagate Logo RGB.png" width="200px" alt=""></a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
      <a class="nav-link" href="#/">Home</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/book">Book Now</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/sails">Dining</a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="#/contact">Contact</a>
      </li>
      <li class="nav-item">
      <a class="nav-link desk" href="https://www.facebook.com/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      <a class="nav-link mobile" href="fb://page/Seagate-Motel-Moonta-Bay-656235891127047" >
      <img src="img/flogo.png" width="25px" alt="facebook" align="middle">
      </a>
      </li>
      <li class="nav-item">
      <a class="nav-link" href="https://www.instagram.com/accounts/login/?hl=en" >
      <img src="img/Instagram.png" width="25px" alt="Instagram" align="middle">
      </a>
      </li>
      </ul>
      </div>
      </div>
      </nav>

      <header>
      <div class="headerimg">
      <img ng-src="{{image.image}}" alt="">
      </div>
      </header>

      <section class="py-5">
      <div class="container">
      <div ng-view></div>
      </div>
      </section>






      html angularjs image routes src






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 23:26









      Andrew Lockwood

      11




      11





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217672%2fset-up-an-ng-src-from-within-routeprovider-to-display-image-elsewhere%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53217672%2fset-up-an-ng-src-from-within-routeprovider-to-display-image-elsewhere%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff