I am writing an angular app which has a Search products page which shows a list of products. When any product is clicked in the search results, the details of the product should appear below the search results. I am implementing this using angular-ui-router with named views. There are separate templates and controllers for search-product and view-product and the controllers share data using a service. Now I want to show the viewProduct view to only appear when a search-result is clicked on and remain hidden if nothing is clicked. How can I accomplish this ?
Following is the implementation:
$stateProvider
.state('home', {
templateUrl: "search.html"
})
.state('home.search',{
url:'/search',
views:{
'searchProducts':{
templateUrl: 'search-products.html',
controller: 'SearchProductsController'
},
'viewProduct':{
templateUrl: 'view-product.html',
controller: 'ViewProductController'
}
})
search.html
<div ui-view="searchProducts"></div>
<div ui-view="viewProduct"></div>
index.html
<div ui-view></div>