{"id":19569,"date":"2017-01-12T19:51:33","date_gmt":"2017-01-12T19:51:33","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=19569"},"modified":"2018-11-14T16:53:11","modified_gmt":"2018-11-14T16:53:11","slug":"web-programming-angularjs-part-2","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/web-programming-angularjs-part-2\/","title":{"rendered":"Web programming:  AngularJS, part 2"},"content":{"rendered":"<h1>The tutor shows an example of AngularJS in action, with JavaScript&#8217;s Math.pow(x,y) function.<\/h1>\n<p><script src=\"http:\/\/ajax.googleapis.com\/ajax\/libs\/angularjs\/1.4.8\/angular.min.js\"><\/script><br \/>\n<script src=\"\/javascripts\/angjs_jan12_2017.js\"><\/script><br \/>\nJavaScript&#8217;s function Math.pow(3,4) evaluates 3<sup>4<\/sup>, giving the answer 81.  In that expression, 3 is the base, while 4 is the exponent.<\/p>\n<p>Below, you can input a base and exponent and receive the answer from JavaScript&#8217;s Math.pow(base,exponent).<\/p>\n<div data-ng-app=\"theApp\" data-ng-controller=\"theFnc\">\n<p>base, exponent <input type=\"text\" data-ng-model=\"base\" style=\"color:brown;width:10em\" id=\"here\">, <input type=\"text\" data-ng-model=\"exponent\" style=\"color:brown;width:6em\" ><\/p>\n<p><span style=\"color:brown\">{{base}}<\/span> raised to exponent <span style=\"color:brown\">{{exponent}}<\/span> is <span style=\"color:brown\">{{answer()}}<\/span><\/p>\n<\/div>\n<p>The notable feature of this form is that it&#8217;s handled with AngularJS, which binds values as they are entered with expressions elsewhere on the page.  The reason this page needs back-end code is to support the Math.pow() function, which seems unavailable in AngularJS without being brought into the scope, perhaps as follows:<\/p>\n<p style=\"white-space:pre-wrap;color:green\">\nvar app0=angular.module(&#8220;theApp&#8221;,[]);<br \/>\n\tapp0.controller(&#8220;theFnc&#8221;, function($scope){<br \/>\n$scope.base=&#8221;base&#8221;;<br \/>\n$scope.exponent=&#8221;exponent&#8221;;<br \/>\n$scope.answer=function(){<br \/>\nreturn Math.pow($scope.base,$scope.exponent);<br \/>\n}});\n<\/p>\n<p>I&#8217;ll be talking more about AngularJS in coming posts:)<\/p>\n<p>Source:<\/p>\n<p><a href=\"http:\/\/www.w3schools.com\/angular\/angular_scopes.asp\">w3schools.com<\/a><\/p>\n<p><a href=\"http:\/\/www.w3schools.com\/jsref\/jsref_pow.asp\">w3schools.com<\/a><\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The tutor shows an example of AngularJS in action, with JavaScript&#8217;s Math.pow(x,y) function. JavaScript&#8217;s function Math.pow(3,4) evaluates 34, giving the answer 81. In that expression, 3 is the base, while 4 is the exponent. Below, you can input a base &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/web-programming-angularjs-part-2\/\"> <span class=\"screen-reader-text\">Web programming:  AngularJS, part 2<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105,1745,1855],"tags":[2100,2101],"class_list":["post-19569","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-javascript-computer-science","category-web-programming","tag-angularjs-scope","tag-javascript-math-pow-function"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=19569"}],"version-history":[{"count":18,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19569\/revisions"}],"predecessor-version":[{"id":36176,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/19569\/revisions\/36176"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=19569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=19569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=19569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}