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
html angularjs image routes src
add a comment |
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
html angularjs image routes src
add a comment |
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
html angularjs image routes src
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
html angularjs image routes src
asked Nov 8 at 23:26
Andrew Lockwood
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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