0
angular.module('InvoicerApp')
.directive('invoice', function() {
return {
restrict: 'E',
templateUrl: 'templates/invoice-directive.html',
scope: true
};
});
發票directive.html事件
<div class="row">
<div class="col-md-1">
<input type="text" ng-model="invoice.product.tax" class="form-control input-sm" placeholder="TVA">
</div>
<div class="col-md-1">
<select type="text" ng-model="invoice.product.includeTax" class="form-control input-sm" placeholder="TVA?">
<option value="true" selected>Include TVA</option>
<option value="false">Nu include TVA</option>
</select>
</div>
<div class="col-md-1">
<button type="text" ng-model="invoice.product.add" class="btn btn-primary btn-sm" ng-click="invoiceAddProduct()">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>
</div>
控制器
$scope.invoice = {};
$scope.invoice.products = [];
$scope.client = {};
$scope.invoiceAddProduct = function() {
console.log("HELLO");
};
invoiceAddProduct沒有從該指令模板內被解僱。我如何從控制器的指令模板內部訪問模型?
能否請您發表您的HTML,你必須包括指令? – Ritesh
謝謝:)我剛剛發現我沒有發起控制器... :) – Sherlock