javascript - How to convert jQuery code into usable AngularJS code -
javascript - How to convert jQuery code into usable AngularJS code -
i new angularjs , create functionality login page similar find here when click 'forgot password' link:
http://bootsnipp.com/snippets/featured/login-amp-password-reminder#comments
is best utilize directive, since behavioral, instead of controller? i've tried quite bit creating controller it, search help on subject find using controller may not way go. here latest trials unsuccessful (the link nil when clicked):
on controller side in js file:
angular.module('mean.users') .controller('switcherctrl', ['$document', function($document) { $document.ready(function () { $document.getelementbyid('olvidado').click(function (e) { e.preventdefault(); $document.getelementbyid('form-olvidado').toggle('500'); }); $document.getelementbyid('acceso').click(function (e) { e.preventdefault(); $document.getelementbyid('form-olvidado').toggle('500'); }); }); } ])
on html side, included ng-controller="switcherctrl" necessary.
jquery approach incompatible angularjs. dom manipulation allowed in directives in link function otherwise bad practice. seek start scratch , forget jquery. magic of angularjs happens 2-way bindings.
you utilize directive, login controller , factory/service hold username , password , send database. login there no need jquery @ all. can check question here: angularjs- login , authentication in each route , controller
edit: in question above, not directive instead of controller. directive can have controller applied specific scope. same thing both depends how many times reuse login snippet - guess won't need believe still practice create one.
edit 2: if havent' read one, please it! believe reply of questions 2 different (opposite say) technologies. how "think in angularjs" if have jquery background? since came jquery background too, followed these 4 resources in order , can create of things want:
introduction angular.js in 50 examples (part 1) https://www.youtube.com/watch?v=trrl5j3mivo
introduction angular.js in 50 examples (part 2) https://www.youtube.com/watch?v=6j08m1h2bme
free interactive angularjs learning beginners https://www.codeschool.com/courses/shaping-up-with-angular-js
more angularjs resources topic egghead.io https://egghead.io/technologies/angularjs
javascript jquery angularjs controller directive
Comments
Post a Comment