Skip to content Skip to sidebar Skip to footer

Controller Data Set Another Page In Angular

After that clicked user.html list. I have to show clicked product data in productDetail.html file. ProductController.js $scope.selectedProduct = function(product) { console.

Solution 1:

Need more Clarification, whether both HTML are shown in same view or different on product click.

here is a Plunker i made understanding your question and comments. https://plnkr.co/edit/Ii52KZkjpNndmAMvQQYU?p=preview

  $scope.products = [{
    ID: 'P1',
    post_title: 'product 1',
    post_date: '20th July 2016',
    post_author: 'John Doe'
  }, {
    ID: 'P2',
    post_title: 'product 2',
    post_date: '29th July 2016',
    post_author: 'Jane Doe'
  }, {
    ID: 'P3',
    post_title: 'product 3',
    post_date: '12th July 2016',
    post_author: 'John William'
  }];
  $scope.selectedProduct = {};
  $scope.selectProduct = function(index){
    $scope.selectedProduct = $scope.products[index];
  };

and here is the HTML

<div>
    Product List
    <divng-repeat="product in products"><ion-item>
          {{product.post_title}}
          <buttonng-click="selectProduct($index)">select</button><br></ion-item></div></div><divng-include="'product.html'"></div>

the other HTML will pick the same angular controller.

Post a Comment for "Controller Data Set Another Page In Angular"