Benutzer:MovGP0/AngularJS/Validation
aus Wikipedia, der freien Enzyklopädie
< Benutzer:MovGP0 | AngularJS
MovGP0 | Über mich | Hilfen | Artikel | Weblinks | Literatur | Zitate | Notizen | Programmierung | MSCert | Physik |
AngularJS Validation
class PassengerController {
private _passenger: IPassenger;
private _index: number;
private _passengersForm : IFormController;
get viewOnly() {
return this._viewOnly;
}
get passengersForm(): any {
return this._passengersForm;
}
static $inject = ["$scope"];
constructor($scope: IPassengerDirectiveScope) {
this._passenger = $scope.passenger as IHomeDeliveryFlightBaggagePassenger;
this._index = $scope.index; // nth element
this._passengersForm = $scope.passengersForm;
}
//...
interface IPassengerDirectiveScope extends angular.IScope {
passengersForm: angular.IFormController;
index: number;
passenger: IHomeDeliveryFlightBaggagePassenger;
}
angular.module("...", [])
.directive("myPassenger", (): ng.IDirective => ({
restrict: "E", // Dircetive als Element
scope: {
passenger: "=", // <my-passenger ng-foreach="p in passengers" passenger="p">
},
require: "^form",
link: (scope: IPassengerDirectiveScope, element: angular.IAugmentedJQuery, attributes: angular.IAttributes, ngFormController: angular.IFormController) => {
scope.index = scope.$parent.$index;
scope.passengersForm = ngFormController;
},
templateUrl: "components/passenger/passenger.html",
controller: PassengerController,
controllerAs: "controller"
}));
Externe Links
|