【发布时间】:2016-07-15 01:25:26
【问题描述】:
我还是 angularJs 的新手,我正在尝试将一个变量的值从一个页面 html 传递到另一个页面(实际上是一个模式)。两个页面共享同一个控制器。请帮我诊断一下铅
Html Page1:
<button type="submit" class="btn btn-primary pull-right"
data-ng-click="ctrl.nextOperation(chosenProducts,'lg')">Next</button>
</div>
app.js:
self.nextOperation = function(chosenProducts,size)
{
$scope.chosenProducts= chosenProducts;
$scope.product = chosenProducts[0];
console.log($scope.product.nameProduct);
console.log("test test nextt Operation "+chosenProducts[0].nameProduct);
var modalInstance = $uibModal.open({
animation : $scope.animationsEnabled,
templateUrl : 'partials/operation.html',
controller : 'ProductsController',
scope : $scope,
size : size,
resolve : {
}
});
};
第 2 页:
<table>
<tbody>
<tr class="cake-bottom" >
<td class="cakes">
<div class="product-img2">
</div>
</td>
<td class="cake-text">
<div class="product-text">
<h3>{{product.nameProduct}}</h3>
<p>Product Code: {{product.numSerie}}</p>
</div>
</td>
<td class="quantity">
<div class="product-right">
<input min="1" type="number" id="quantity" name="quantity" value="" class="form-control input-small">
</div>
</td>
<td>
<h4>{{product.price}}</h4>
</td>
<td class="btm-remove">
<div class="close-btm">
<h5>Remove</h5>
</div>
</td>
</tr>
</tbody>
</table>
【问题讨论】:
-
查看stackoverflow.com/a/33164461/178163 尝试像这样访问它,例如:{{$parent.product.price}}
-
通过 $parent 访问不是很好。您正在制作一个高度耦合的应用程序,这总是很糟糕。
标签: javascript angularjs