Angular: Empty Fiddle
http://angularjs.org/
by redoak2000
HTML
<script id="partials/addressform.html" type="text/ng-template">
//directive of type {{type}} with value {{type.value}}<br>
//<a >========= {{type.value}} =======</a><br>
<button type="button"
style="max-width:30%"
class="button icon-left ion-android-done" ng-disabled="pinForm.$invalid"
ng-click="$scope.$parent.submit()">
{{type.value}}
</button>
</script>
<div ng-controller="MyCtrl">
<form name="pinForm" role="form" ng-submit="submit()">
<div class="item item-input item-button-right">
<span class="input-label">名称</span>
<input type="text" placeholder="不超过50个字" class="form-control"
ng-minlength="1" required
ng-model="model.name" ng-maxlength="8" />
</div>
<address-form type="billing"></address-form>
<button type="button"
style="max-width:30%"
class="button icon-left ion-android-done" ng-disabled="pinForm.$invalid" ng-click="submit()">
native
</button>
</form>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
angular.module('myApp').directive('addressForm', function() {
return {
restrict: 'E',
templateUrl: 'partials/addressform.html',
scope: {
type: '='
}
};
});
angular.module('myApp').controller('MyCtrl', function($scope) {
$scope.model ={name:'hello'};
$scope.billing = { type: 'billing type', value: 'abc' };
$scope.delivery = { type: 'delivery type', value: 'def' };
$scope.submit = function(){alert('hello');};
});