{"id":400,"date":"2017-04-04T03:27:16","date_gmt":"2017-04-04T03:27:16","guid":{"rendered":"http:\/\/kaizen-koka.com\/?p=400"},"modified":"2017-04-04T03:28:16","modified_gmt":"2017-04-04T03:28:16","slug":"angularjs-1-0","status":"publish","type":"post","link":"https:\/\/kaizen-koka.com\/?p=400","title":{"rendered":"AngularJS 1.0"},"content":{"rendered":"<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>&#8211; <\/strong>AngularJS is a single page application framework<br \/>\n\t<strong>&#8211;<\/strong> AngularJS provides a robust &#39;SPA&#39; framework for building robust client-centric applications.<br \/>\n\t<strong>&#8211;<\/strong> Views, Controllers &amp; Scope<br \/>\n\t<strong>&#8211; <\/strong>Modules, Routes, and Factories<br \/>\n\t<strong>&#8211; <\/strong>AngularJS is a one core library &#8211; no dependencies on others.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>What is SPA?<\/strong><br \/>\n\t&#8211; Where we will have a shell page and loads multiple views into that.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Features:<\/strong><br \/>\n\t&#8211; Two-way data binding<br \/>\n\t&#8211; MVC concepts support<br \/>\n\t&#8211; Routing techniques<br \/>\n\t&#8211; Testing<br \/>\n\t&#8211; JqLite(jquery for DOM manipulation)<br \/>\n\t&#8211; Support for templates(when we go for data binding)<br \/>\n\t&#8211; Share code(reusability) through factories and other services<br \/>\n\t&#8211; Databinding with ViewModels<br \/>\n\t&#8211; Directives, Validations, Dependency Injections<br \/>\n\t&#8211; <strong>Key Features<\/strong> like Directives, two-way data binding, views, controllers, scope, modules, and routes.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Directives <\/strong>&#8211; It&#39;s a way to teach html new tricks<br \/>\n\tng-app : it initializes the angular app<br \/>\n\tng-model : binds an input to a property on the scope using ngModel Controller.<br \/>\n\tdatabinding expression : {{}}<br \/>\n\tng-init =&quot;names=[&#8216;siva&#8217;,&#8217;kamal&#8217;]&quot;<br \/>\n\tng-repeat : Instantiates a template once per item from a collection.<br \/>\n\tng-bind : Used to replace the text context of the html element with value of a given expression.<br \/>\n\tng-controller : Attaches the controller class to the view.<br \/>\n\tng-view : placeholders for view.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Filters:<\/strong> Selects a subset of items from array &amp; returns it as a new array using pipe operator(|)<br \/>\n\t{{filter-expression | filter:expression:comparator}}<br \/>\n\torderBy, uppercase, limitTo, number, date, currency<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>View, Controllers &amp; Scope<\/strong>(viewModel &#8211; integrate between view &amp; controller)<br \/>\n\t-$scope is the glue(viewModel) between a controller and a view.<br \/>\n\t&lt;div data-ng-controller=&quot;SimpleController&quot;&gt;<br \/>\n\t&nbsp;&lt;li data-ng-repeat=&quot;cust in customers&quot;&gt; &nbsp;&#8211; Accessing the $scope<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\">&nbsp;&lt;script&gt;<br \/>\n\t&nbsp;function SimpleController($scope){<br \/>\n\t&nbsp;$scope.customers =[{name:&#8217;Koka&#8217;, City:&#8217;VA&#8217;},{name:&#8217;siva&#8217;, city:&#8217;az&#8217;}]<br \/>\n\t&nbsp;}<\/span><\/span>\n<\/p>\n<p>\n\t<a href=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"401\" data-permalink=\"https:\/\/kaizen-koka.com\/?attachment_id=401\" data-orig-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?fit=1124%2C718&amp;ssl=1\" data-orig-size=\"1124,718\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-04-03 at 8.12.48 PM\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?fit=300%2C192&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?fit=1024%2C654&amp;ssl=1\" alt=\"\" class=\"aligncenter size-full wp-image-401\" height=\"718\" src=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?resize=1124%2C718\" width=\"1124\" srcset=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?w=1124&amp;ssl=1 1124w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?resize=300%2C192&amp;ssl=1 300w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?resize=768%2C491&amp;ssl=1 768w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-8.12.48-PM.png?resize=1024%2C654&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a> <a href=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"402\" data-permalink=\"https:\/\/kaizen-koka.com\/?attachment_id=402\" data-orig-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?fit=1638%2C508&amp;ssl=1\" data-orig-size=\"1638,508\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Screen Shot 2017-04-03 at 9.00.40 PM\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?fit=300%2C93&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?fit=1024%2C318&amp;ssl=1\" alt=\"\" class=\"aligncenter size-full wp-image-402\" height=\"508\" src=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?resize=1638%2C508\" width=\"1638\" srcset=\"https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?w=1638&amp;ssl=1 1638w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?resize=300%2C93&amp;ssl=1 300w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?resize=768%2C238&amp;ssl=1 768w, https:\/\/i0.wp.com\/kaizen-koka.com\/wp-content\/uploads\/2017\/04\/Screen-Shot-2017-04-03-at-9.00.40-PM.png?resize=1024%2C318&amp;ssl=1 1024w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/a>\n<\/p>\n<p>\n\t<br \/>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Modules, Routes, &nbsp;Factories &amp; Services<\/strong><br \/>\n\t-Module can have config function &amp; this config can be used to define different routes.&nbsp;<br \/>\n\t-Two things can be defined in Route, view &amp; controller<br \/>\n\t-Controller can have factory or services to get the data, manipulate the data, CRUD operations.<br \/>\n\t-On views, we have directives to support.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\">&lt;html ng-app=&quot;moduleName&quot;&gt;&nbsp;<br \/>\n\t&nbsp;var demoApp = angular.module(&#39;demoApp&#39;,[]);<br \/>\n\t&nbsp; &nbsp;[] is where you can add dependency modules(dependency injection) like helper module.<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Defining Routes<\/strong> :<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\">var demoAPP = angular.module(&#39;demoApp&#39;,[]);<br \/>\n\tdemoApp.config(function($routeProvider)){<br \/>\n\t&nbsp;&nbsp; &nbsp;$routeProvider<br \/>\n\t&nbsp;&nbsp; &nbsp;.when(&#39;\/&#39;,<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; controller:&#39;SimpleController&#39;,<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; templateUrl:&#39;view1.htm&#39;<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; })<br \/>\n\t&nbsp;&nbsp; &nbsp;.when(&#39;\/partial&#39;,<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; {<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; controller:&#39;SimpleController&#39;,<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; templateUrl:&#39;view2.htm&#39;<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; })<br \/>\n\t&nbsp;&nbsp; &nbsp; .otherwise({<br \/>\n\t&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; redirectTo:&#39;\/&#39;<br \/>\n\t&nbsp;&nbsp; &nbsp; }) &nbsp; &nbsp;<br \/>\n\t});<br \/>\n\tdemoApp.controller(&#39;simpleController&#39;, function($scope)){<br \/>\n\t&nbsp;&nbsp; &nbsp;$scope.customers =[{name:koka,city:va},{name:siva,city:va}]});<\/span><\/span>\n<\/p>\n<p>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\"><strong>Factory, Service &amp; Providers&nbsp;<\/strong><br \/>\n\t&nbsp; &#8211; Allows us to encapsulate common functionalities. Difference is the way &amp; which they get the data from backend system.<br \/>\n\t&nbsp; &#8211; Factory injected in to the controller at runtime.<br \/>\n\t&nbsp; var demoApp = angular.module(&#39;demoApp&#39;,[])<br \/>\n\t&nbsp; .factory(&#39;simpleFactory&#39;,function(){<br \/>\n\t&nbsp; var factory = {};<br \/>\n\t&nbsp; var customers = [&#8230;];<br \/>\n\t&nbsp; factory.getCustomers = function(){<br \/>\n\t&nbsp; &nbsp; return customers;};<br \/>\n\t&nbsp; return factory;})<br \/>\n\t&nbsp; .controller(&#39;simpleController&#39;, function($scope, simpleFactory){<br \/>\n\t&nbsp; &nbsp; $scope.customers = simpleFactory.getCustomers();<br \/>\n\t&nbsp; })<\/span><\/span>\n<\/p>\n<p>\n\t<br \/>\n\t<span style=\"font-size:14px;\"><span style=\"font-family:tahoma,geneva,sans-serif;\">$rootscope : rootScope avaliabile globally<br \/>\n\t$scope : only avaliable to the controller that has created and its children.<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8211; AngularJS is a single page application framework &#8211; AngularJS provides a robust &#39;SPA&#39; framework for building robust client-centric applications. &#8211; Views, Controllers &amp; Scope &#8211; Modules, Routes, and Factories [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[22],"tags":[],"class_list":["post-400","post","type-post","status-publish","format-standard","hentry","category-ui"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p70lnf-6s","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/400","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=400"}],"version-history":[{"count":1,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/400\/revisions"}],"predecessor-version":[{"id":403,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=\/wp\/v2\/posts\/400\/revisions\/403"}],"wp:attachment":[{"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=400"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=400"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kaizen-koka.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=400"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}