We will take user input and in return displays reversed output of that input string. Factory comes into picture to give an instance which contains getter and setter method. We define decorator for this Factory instance and reverse input string set via setter method.
Script for Factory and Decorator:
'use strict' var app = angular.module('DecoratorApp', []); app.controller("decoratorController", function($scope, reverseFactory) { $scope.reverseCall = function() { reverseFactory.setData($scope.inputVal); reverseFactory.reverse(); $scope.outputVal = reverseFactory.getData(); } }); app.factory('reverseFactory', function() { var myPrivateData; return { getData : function() { return myPrivateData }, setData : function(data) { return myPrivateData = data } } }) /* Decoration created for factory reverseFactory */ app.config(function($provide) { $provide.decorator('reverseFactory', function($delegate) { $delegate.reverse = function() { $delegate.setData($delegate.getData().split('') .reverse().join('')) } return $delegate }) })
HTML for input and output :
<html lang="en"> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Filter application</title> </head> <body ng-app="DecoratorApp" ng-controller="decoratorController" ng-cloak> <div class="mainBody"> <div class="mainBodyMinHeight"> <img ng-src="https://toddmotto.com/img/tags/angularjs.svg" height="100px"> <p> <label>Input String: </label> </p> <div flex="100"> <input type='text' ng-model="inputVal" ng-blur="reverseCall()" /> </div> <hr /> Reversed String: <div flex="100"> <p>{{outputVal}}</p> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/ 1.4.3/angular.min.js"></script> <script src="scripts/decoratorApp.js"></script> </body> </html>
Output:-
Download complete source code.
ReplyDeleteThese are really amazing and valuable websites you have shared with us. Thanks for the informative post. Keep posting like this information.
hr solutions in Chennai | hr consultancy in Chennai | hr recruiter in chennai
Call Girls in Mumbai
ReplyDeleteCall Girls in Faridabad
Call Girls in Gurgaon
Call Girls in Gurgaon
Call Girls in Jaipur
Call Girls in Jaipur
Call Girls in Bangalore
Call Girls in Jaipur
Call Girls in Aerocity
ReplyDeleteCall Girls in Aerocity
Call Girls in Aerocity
Escort Service in Aerocity
Escort Service in Aerocity
Female Escorts in Aerocity
Russian Escorts in Aerocity
Great Article
ReplyDeleteFinal Year Projects for CSE in Angular
Angular Training in Chennai
Project Centers in Chennai
JavaScript Training in Chennai
ReplyDeleteOur Russian Escorts in Mahipalpur have smooth bodies that can prepare you for a night of sexual loving. You don’t want to feel self-conscious as you’re safe here at our Call Girls agency. Our Services are all-time service that is accessible for you 24*7 hours. Our Escorts Girls are always prepared to make you fill you’ll have a fantastic alluring night with our lovely girls and you only need for believing simultaneously. Check our other Services also...
Call Girl in Chanakyapuri
Independent Call Girls in Ahmedabad
Escorts in Agra
Call Girls in Pune
ReplyDeleteWe have been in the industry for several years now and have been able to satisfy hundreds of clients who have come back to us wanting more. Our Escorts Service in Agra to book so that their needs may be fulfilled. We establish a detailed conversation with our clients and help them choose the best amongst the various choices available.
Female Escorts in Agra
Russian Escorts in Agra
Female Escorts in Faridabad
Call Girls in Faridabad
ReplyDeleteAlso known to come with crucial offerings for its sensible, down-to-earth and important clients,Call Girls in Gurgaon really means in fulfilling their lives with cheerful moments to make love in concern to ensure them live their lives in abetter way. Check our other Services...
Charges of Call Girls in Gurgaon
Escorts Service in Gurgaon
Female Escorts in Gurgaon
Gurgaon Escorts Service
Housewife Escorts in Gurgaon
Enjoy Our Escorts Service in Gurgaon You can visit our online website given below Click on link for more Details...
ReplyDeleteTop Class Call Girls in Gurgaon
VIP Call Girls in Gurgaon
Russian Escorts in Gurgaon
Escorts in Gurgaon
Call Girls in Gurgaon
Call Girls Prices in Gurgaon
Model Escorts in Gurgaon
Hi Profile Call Girls in Gurgaon
Independent Call Girls in Gurgaon