<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MbarekTheEagle</title>
    <description>The latest articles on DEV Community by MbarekTheEagle (@mbarekderadler).</description>
    <link>https://dev.to/mbarekderadler</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1324933%2Fcad8b143-18a6-4de3-9d24-2c796326c946.png</url>
      <title>DEV Community: MbarekTheEagle</title>
      <link>https://dev.to/mbarekderadler</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mbarekderadler"/>
    <language>en</language>
    <item>
      <title>PHP Data Types</title>
      <dc:creator>MbarekTheEagle</dc:creator>
      <pubDate>Mon, 04 Mar 2024 17:53:41 +0000</pubDate>
      <link>https://dev.to/mbarekderadler/php-data-types-2p54</link>
      <guid>https://dev.to/mbarekderadler/php-data-types-2p54</guid>
      <description>&lt;p&gt;Variables can store data of different types, and different data types can do different things.&lt;/p&gt;

&lt;p&gt;PHP supports the following data types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Integer&lt;/li&gt;
&lt;li&gt;Float (floating point numbers - also called double)&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Array&lt;/li&gt;
&lt;li&gt;Object&lt;/li&gt;
&lt;li&gt;NULL&lt;/li&gt;
&lt;li&gt;Resource&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Getting the Data Type&lt;/strong&gt;&lt;br&gt;
You can get the data type of any object by using the var_dump() function.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
The var_dump() function returns the data type and the value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = 5;
var_dump($x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP String&lt;/strong&gt;&lt;br&gt;
A string is a sequence of characters, like "Hello world!".&lt;/p&gt;

&lt;p&gt;A string can be any text inside quotes. You can use single or double quotes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = "Hello world!";
$y = 'Hello world!';

var_dump($x);
echo "&amp;lt;br&amp;gt;";
var_dump($y);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP Integer&lt;/strong&gt;&lt;br&gt;
An integer data type is a non-decimal number between -2,147,483,648 and 2,147,483,647.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rules for integers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An integer must have at least one digit&lt;br&gt;
An integer must not have a decimal point&lt;br&gt;
An integer can be either positive or negative&lt;br&gt;
Integers can be specified in: decimal (base 10), hexadecimal (base 16), octal (base 8), or binary (base 2) notation&lt;br&gt;
In the following example $x is an integer. The PHP var_dump() function returns the data type and value:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = 5985;
var_dump($x);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP Float&lt;/strong&gt;&lt;br&gt;
A float (floating point number) is a number with a decimal point or a number in exponential form.&lt;/p&gt;

&lt;p&gt;In the following example $x is a float. The PHP var_dump() function returns the data type and value:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = 10.365;
var_dump($x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP Boolean&lt;/strong&gt;&lt;br&gt;
A Boolean represents two possible states: TRUE or FALSE.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = true;
var_dump($x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Booleans are often used in conditional testing.&lt;/p&gt;

&lt;p&gt;You will learn more about conditional testing in the PHP If...Else chapter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PHP Array&lt;/strong&gt;&lt;br&gt;
An array stores multiple values in one single variable.&lt;/p&gt;

&lt;p&gt;In the following example $cars is an array. The PHP var_dump() function returns the data type and value:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$cars = array("Volvo","BMW","Toyota");
var_dump($cars);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP Object&lt;/strong&gt;&lt;br&gt;
Classes and objects are the two main aspects of object-oriented programming.&lt;/p&gt;

&lt;p&gt;A class is a template for objects, and an object is an instance of a class.&lt;/p&gt;

&lt;p&gt;When the individual objects are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties.&lt;/p&gt;

&lt;p&gt;Let's assume we have a class named Car that can have properties like model, color, etc. We can define variables like $model, $color, and so on, to hold the values of these properties.&lt;/p&gt;

&lt;p&gt;When the individual objects (Volvo, BMW, Toyota, etc.) are created, they inherit all the properties and behaviors from the class, but each object will have different values for the properties.&lt;/p&gt;

&lt;p&gt;If you create a __construct() function, PHP will automatically call this function when you create an object from a class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
  public $color;
  public $model;
  public function __construct($color, $model) {
    $this-&amp;gt;color = $color;
    $this-&amp;gt;model = $model;
  }
  public function message() {
    return "My car is a " . $this-&amp;gt;color . " " . $this-&amp;gt;model . "!";
  }
}

$myCar = new Car("red", "Volvo");
var_dump($myCar);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;PHP NULL Value&lt;/strong&gt;&lt;br&gt;
Null is a special data type which can have only one value: NULL.&lt;/p&gt;

&lt;p&gt;A variable of data type NULL is a variable that has no value assigned to it.&lt;/p&gt;

&lt;p&gt;Tip: If a variable is created without a value, it is automatically assigned a value of NULL.&lt;/p&gt;

&lt;p&gt;Variables can also be emptied by setting the value to NULL:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = "Hello world!";
$x = null;
var_dump($x);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Change Data Type&lt;/strong&gt;&lt;br&gt;
If you assign an integer value to a variable, the type will automatically be an integer.&lt;/p&gt;

&lt;p&gt;If you assign a string to the same variable, the type will change to a string:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$x = 5;
var_dump($x);

$x = "Hello";
var_dump($x);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>JavaScript Math Object</title>
      <dc:creator>MbarekTheEagle</dc:creator>
      <pubDate>Mon, 04 Mar 2024 17:48:22 +0000</pubDate>
      <link>https://dev.to/mbarekderadler/javascript-math-object-14ff</link>
      <guid>https://dev.to/mbarekderadler/javascript-math-object-14ff</guid>
      <description>&lt;p&gt;The JavaScript Math object allows you to perform mathematical tasks on numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Math.PI;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Math Object&lt;/strong&gt;&lt;br&gt;
Unlike other objects, the Math object has no constructor.&lt;/p&gt;

&lt;p&gt;The Math object is static.&lt;/p&gt;

&lt;p&gt;All methods and properties can be used without creating a Math object first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Math Properties (Constants)&lt;/strong&gt;&lt;br&gt;
The syntax for any Math property is : Math.property.&lt;/p&gt;

&lt;p&gt;JavaScript provides 8 mathematical constants that can be accessed as Math properties:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.E        // returns Euler's number
Math.PI       // returns PI
Math.SQRT2    // returns the square root of 2
Math.SQRT1_2  // returns the square root of 1/2
Math.LN2      // returns the natural logarithm of 2
Math.LN10     // returns the natural logarithm of 10
Math.LOG2E    // returns base 2 logarithm of E
Math.LOG10E   // returns base 10 logarithm of E
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Math Methods&lt;/strong&gt;&lt;br&gt;
The syntax for Math any methods is : Math.method(number)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Number to Integer&lt;/strong&gt;&lt;br&gt;
There are 4 common methods to round a number to an integer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.round(x)   Returns x rounded to its nearest integer
Math.ceil(x)    Returns x rounded up to its nearest integer
Math.floor(x)   Returns x rounded down to its nearest integer
Math.trunc(x)   Returns the integer part of x (new in ES6)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Math.round()&lt;/strong&gt;&lt;br&gt;
Math.round(x) returns the nearest integer:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Math.round(4.6);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Math.ceil()&lt;/strong&gt;&lt;br&gt;
Math.ceil(x) returns the value of x rounded up to its nearest integer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.ceil(4.9);
Math.ceil(4.7);
Math.ceil(4.4);
Math.ceil(4.2);
Math.ceil(-4.2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Math.floor()&lt;/strong&gt;&lt;br&gt;
Math.floor(x) returns the value of x rounded down to its nearest integer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.floor(4.9);
Math.floor(4.7);
Math.floor(4.4);
Math.floor(4.2);
Math.floor(-4.2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Math.trunc()&lt;/strong&gt;&lt;br&gt;
Math.trunc(x) returns the integer part of x:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Math.trunc(4.9);
Math.trunc(4.7);
Math.trunc(4.4);
Math.trunc(4.2);
Math.trunc(-4.2);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>React Forms</title>
      <dc:creator>MbarekTheEagle</dc:creator>
      <pubDate>Mon, 04 Mar 2024 17:43:00 +0000</pubDate>
      <link>https://dev.to/mbarekderadler/react-forms-hc3</link>
      <guid>https://dev.to/mbarekderadler/react-forms-hc3</guid>
      <description>&lt;p&gt;Just like in HTML, React uses forms to allow users to interact with the web page.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding Forms in React&lt;br&gt;
You add a form with React like any other element:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function MyForm() {
  return (
    &amp;lt;form&amp;gt;
      &amp;lt;label&amp;gt;Enter your name:
        &amp;lt;input type="text" /&amp;gt;
      &amp;lt;/label&amp;gt;
    &amp;lt;/form&amp;gt;
  )
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(&amp;lt;MyForm /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will work as normal, the form will submit and the page will refresh.&lt;/p&gt;

&lt;p&gt;But this is generally not what we want to happen in React.&lt;/p&gt;

&lt;p&gt;We want to prevent this default behavior and let React control the form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handling Forms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Handling forms is about how you handle the data when it changes value or gets submitted.&lt;/p&gt;

&lt;p&gt;In HTML, form data is usually handled by the DOM.&lt;/p&gt;

&lt;p&gt;In React, form data is usually handled by the components.&lt;/p&gt;

&lt;p&gt;When the data is handled by the components, all the data is stored in the component state.&lt;/p&gt;

&lt;p&gt;You can control changes by adding event handlers in the onChange attribute.&lt;/p&gt;

&lt;p&gt;We can use the useState Hook to keep track of each inputs value and provide a "single source of truth" for the entire application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;br&gt;
Use the useState Hook to manage the input:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';
import ReactDOM from 'react-dom/client';

function MyForm() {
  const [name, setName] = useState("");

  return (
    &amp;lt;form&amp;gt;
      &amp;lt;label&amp;gt;Enter your name:
        &amp;lt;input
          type="text" 
          value={name}
          onChange={(e) =&amp;gt; setName(e.target.value)}
        /&amp;gt;
      &amp;lt;/label&amp;gt;
    &amp;lt;/form&amp;gt;
  )
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(&amp;lt;MyForm /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Submitting Forms&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can control the submit action by adding an event handler in the onSubmit attribute for the &lt;/p&gt;:

&lt;p&gt;&lt;strong&gt;Example:&lt;br&gt;
Add a submit button and an event handler in the onSubmit attribute:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';
import ReactDOM from 'react-dom/client';

function MyForm() {
  const [name, setName] = useState("");

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    alert(`The name you entered was: ${name}`)
  }

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;label&amp;gt;Enter your name:
        &amp;lt;input 
          type="text" 
          value={name}
          onChange={(e) =&amp;gt; setName(e.target.value)}
        /&amp;gt;
      &amp;lt;/label&amp;gt;
      &amp;lt;input type="submit" /&amp;gt;
    &amp;lt;/form&amp;gt;
  )
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(&amp;lt;MyForm /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;Multiple Input Fields&lt;/strong&gt;&lt;br&gt;
You can control the values of more than one input field by adding a name attribute to each element.&lt;/p&gt;

&lt;p&gt;We will initialize our state with an empty object.&lt;/p&gt;

&lt;p&gt;To access the fields in the event handler use the event.target.name and event.target.value syntax.&lt;/p&gt;

&lt;p&gt;To update the state, use square brackets [bracket notation] around the property name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;br&gt;
Write a form with two input fields:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { useState } from 'react';
import ReactDOM from 'react-dom/client';

function MyForm() {
  const [inputs, setInputs] = useState({});

  const handleChange = (event) =&amp;gt; {
    const name = event.target.name;
    const value = event.target.value;
    setInputs(values =&amp;gt; ({...values, [name]: value}))
  }

  const handleSubmit = (event) =&amp;gt; {
    event.preventDefault();
    alert(inputs);
  }

  return (
    &amp;lt;form onSubmit={handleSubmit}&amp;gt;
      &amp;lt;label&amp;gt;Enter your name:
      &amp;lt;input 
        type="text" 
        name="username" 
        value={inputs.username || ""} 
        onChange={handleChange}
      /&amp;gt;
      &amp;lt;/label&amp;gt;
      &amp;lt;label&amp;gt;Enter your age:
        &amp;lt;input 
          type="number" 
          name="age" 
          value={inputs.age || ""} 
          onChange={handleChange}
        /&amp;gt;
        &amp;lt;/label&amp;gt;
        &amp;lt;input type="submit" /&amp;gt;
    &amp;lt;/form&amp;gt;
  )
}

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(&amp;lt;MyForm /&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;



</description>
    </item>
    <item>
      <title>Angular JS Routing</title>
      <dc:creator>MbarekTheEagle</dc:creator>
      <pubDate>Mon, 04 Mar 2024 17:32:50 +0000</pubDate>
      <link>https://dev.to/mbarekderadler/angular-js-routing-4366</link>
      <guid>https://dev.to/mbarekderadler/angular-js-routing-4366</guid>
      <description>&lt;p&gt;If you want to navigate to different pages in your application, but you also want the application to be a SPA (Single Page Application), with no page reloading, you can use the ngRoute module.&lt;/p&gt;

&lt;p&gt;The ngRoute module routes your application to different pages without reloading the entire application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;br&gt;
Navigate to "red.htm", "green.htm", and "blue.htm":&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body ng-app="myApp"&amp;gt;

&amp;lt;p&amp;gt;&amp;lt;a href="#/!"&amp;gt;Main&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;

&amp;lt;a href="#!red"&amp;gt;Red&amp;lt;/a&amp;gt;
&amp;lt;a href="#!green"&amp;gt;Green&amp;lt;/a&amp;gt;
&amp;lt;a href="#!blue"&amp;gt;Blue&amp;lt;/a&amp;gt;

&amp;lt;div ng-view&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider) {
  $routeProvider
  .when("/", {
    templateUrl : "main.htm"
  })
  .when("/red", {
    templateUrl : "red.htm"
  })
  .when("/green", {
    templateUrl : "green.htm"
  })
  .when("/blue", {
    templateUrl : "blue.htm"
  });
});
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What do I Need?&lt;br&gt;
To make your applications ready for routing, you must include the AngularJS Route module:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-route.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then you must add the ngRoute as a dependency in the application module:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var app = angular.module("myApp", ["ngRoute"]);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;**Now your application has access to the route module, which provides the $routeProvider.&lt;/p&gt;

&lt;p&gt;Use the $routeProvider to configure different routes in your application:**&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;app.config(function($routeProvider) {
  $routeProvider
  .when("/", {
    templateUrl : "main.htm"
  })
  .when("/red", {
    templateUrl : "red.htm"
  })
  .when("/green", {
    templateUrl : "green.htm"
  })
  .when("/blue", {
    templateUrl : "blue.htm"
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;**Where Does it Go?&lt;br&gt;
Your application needs a container to put the content provided by the routing.&lt;/p&gt;

&lt;p&gt;This container is the ng-view directive.&lt;/p&gt;

&lt;p&gt;There are three different ways to include the ng-view directive in your application:**&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div ng-view&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ng-view&amp;gt;&amp;lt;/ng-view&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;div class="ng-view"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Applications can only have one ng-view directive, and this will be the placeholder for all views provided by the route.&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
