javascript - update model angularJS -
I am trying to understand how AngularJS works with a directive
count-date which calculates the age of months and years, I can not write directly to the data model because I have many fields, but I want to use my code multiple times. HTML:
& lt; Div & gt; First child of birth date Month: & lt; Input type = "text" id = "month" first chald "ng-model = 'month before infant' Required maximum length =" 2 "only-digit month Required calculation-date & gt; Year: & lt; input type = "Text" name = 'nickname before year' ng-model = 'first year's balance' maximum-length = "4" only-digit-year-of-year-expected-count-date & gt; & lt; span ng- Model = "AZFst Chald" & gt; {{Edghestchild}} & lt; div & gt; Second child of date of birth month: & lt; input Type = "article" id = "month" second time "ng-model = 'month' second child 'required maximum length =" 2 "only-digits required number-date & gt; Year: & lt; Input type = "text" name = 'year child child' ng-model = 'year cyqond child' maximum number = "4" only-digit year-of-birth-expected-date & gt; & Lt; Span ng-model = "edge edge chald" & gt; {{Edge Edge Chalk}} & lt; / Span & gt; & Lt; / Div & gt; js:
app.directive ('countDate', function () {return {link: function ($ scope, element, attrs) {element} .bind ('blur', function (event, el) {var el = angular.element (element), month = + el.parent (). Children (). Eq (0) .val (), year = + el (.) Children (). Eq (1) .val (), DateoffBirth = new date (year, month), now = new date (), today = new date (now.Gujaraler), now .getMonth ()), Age = mathematics. ((Now - dateofbirth) / (32140800000);});}};}); I need help writing the instructions again.
If you want to do He is calculating age, writing instructions is a bit of an overkill - you can easily do
The first child of the date of birth: HTML:
HTML: = "1" max = "12" ng-model = "month first stop" required maximum length = "2" /> Year: & lt; input type = "number" min = "0" max = "99 99" ng-model = "first child of the year" required xlength = "4" /> & Lt; Span & gt; {{GetAge (Earfest Child, Month First Baby)}} & lt; / Span & gt; & Lt; / Div & gt; JS (Controller):
$ scope.getAge = function (year, month) {var dateOfBirth = new date (year, month), now = new date (); Now come back. Full time () - dateoffbirth.getfulair (); };
Comments
Post a Comment