I have searched the AngularJS so far and which is a learning curve. Can I recommend any good books that Angular will dive in "practical" in JS. My programming question is:
Consider:
& lt; Input type = "text" name = "inputfilled 1" ng-model = "myModel.firstName" encrypt-and-service = "myModel.encryptedFirstName" />
In my name "Encrypted and saved" I want to dynamically bind to model property whose name is "encryptedFirstName" (in this case) I have read that everything says Is that possible, but I have not found a concrete example of how it is done.
Thank you in advance, Jimmy.
What I'm doing here is doing. I discovered the $ parse and I used $ paras in the initialization and Signature for late / real time binding. Does this make sense or am I completely missing something?
app.directive ('encrypt and save', function ($ parse)) {return {restricted: 'a', requirement: 'ngmodel', link: function (scope, element, etters) , CTLL) {var encrypted model value = $ parse (etter. Encrypt and save); // Wait for model change (can you wait for Blur?) // Scope $ Watch (ethers ngmodel, function (newcomer, oldview) {var encrValue = encryptThis (newValue); encrypted model Valle.assign (scope, encrValue);})}}};});
Thank you for your help, Jimmy
In your instructions Create a separate scope and use the 2-way bond through the '='
scope: {encryptAndSave: '='}
View
var app = angular Module ('app', []); App.controller ('firstCtrl', function ($ scope) {$ scope.myModel = {first name: "which", encrypted first name: "encrypted"};}); App.directive ('encrypt andsave', function () {return: {encryptAndSave: '='}, link: function (scope, elem, attr) {alert (scope.encryptAndSave)}}}});
& lt; Script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2.223/geular.min.js" & gt; & Lt; / Script & gt; & Lt; Body ng-app = "app" & gt; & Lt; Div ng-controller = "firstCtrl" & gt; & Lt; Input type = "text" name = "inputfilled 1" ng-model = "myModel.firstName" Encrypt and save = "myModel.encryptedFirstName" /> & Lt; / Div & gt; & Lt; / Body & gt;
No comments:
Post a Comment