<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Change The Page Title Dynamically &#8211; Sibeesh Passion</title>
	<atom:link href="https://mail.sibeeshpassion.com/tag/change-the-page-title-dynamically/feed/" rel="self" type="application/rss+xml" />
	<link>https://mail.sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 10 Jul 2018 10:35:31 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>Change The Page Title Dynamically &#8211; Sibeesh Passion</title>
	<link>https://mail.sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Change The Page Title Dynamically Using Angular JS</title>
		<link>https://mail.sibeeshpassion.com/change-the-page-title-dynamically-using-angular-js/</link>
					<comments>https://mail.sibeeshpassion.com/change-the-page-title-dynamically-using-angular-js/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Mon, 07 Mar 2016 00:00:16 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Angular JS]]></category>
		<category><![CDATA[Angular JS Service]]></category>
		<category><![CDATA[Change The Page Title Dynamically]]></category>
		<guid isPermaLink="false">http://sibeecst_passion.com/?p=11324</guid>

					<description><![CDATA[In this article we are going to see how we can change the title of a page dynamically using Angular JS. We will be showing random titles which we have already set in an array to the user whenever user reload the same page. To implement this, we are creating angular js controller and service. And we are treating the html tag of our page as our angular js app module and controller. Now shall we go and see this in detail? I hope you will like this. Download the source code You can always download the source code here: [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article we are going to see how we can change the title of a page dynamically using <a href="http://sibeeshpassion.com/category/angularjs" target="_blank">Angular JS</a>. We will be showing random titles which we have already set in an array to the user whenever user reload the same page. To implement this, we are creating angular js controller and service. And we are treating the html tag of our page as our angular js app module and controller. Now shall we go and see this in detail? I hope you will like this.</p>
<p><strong>Download the source code</strong></p>
<p>You can always download the source code here: 	</p>
<li><a href="http://sibeeshpassion.com/Download/CahngePageTitleDynamically.rar" target="_blank">Change The Page Title Dynamically</a></li>
<p><strong>Background</strong></p>
<p>For the past few days I am just doing some experiments with Angular JS. If you want to see my latest articles related to Angular JS, Please see here: <a href="http://sibeeshpassion.com/tag/angular-js/" target="_blank">Angular JS Latest Articles </a>. Here in this post we are going to change the page title dynamically in each user actions. I hope you all know how much important a title tag is in a page. Let us see that first.</p>
<p><strong>Importance Of Title Tag</strong></p>
<li>A title tag add title in browser toolbar</li>
<li>It also provides title for the pages when the page is added to favorites</li>
<li>Positively affect your page ranking in Google search, by displaying title for the page in search result</li>
<p>Now we will start our coding. I hope you will enjoy reading. </p>
<p><strong>Create an Empty Website in Visual Studio</strong></p>
<p>Click File-> New-> Web Site.  </p>
<div id="attachment_11325" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500.png"><img fetchpriority="high" decoding="async" aria-describedby="caption-attachment-11325" src="http://sibeeshpassion.com/wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500.png" alt="Empty Website In Visual Studio" width="650" height="449" class="size-full wp-image-11325" srcset="/wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500.png 650w, /wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500-300x207.png 300w, /wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500-160x110.png 160w, /wp-content/uploads/2016/03/Empty-Website-In-Visual-Studio-e1456922541500-400x276.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11325" class="wp-caption-text">Empty Website In Visual Studio</p></div>
<p><strong>Install Angular JS from NuGet Packages</strong></p>
<p>Once your application is opened, please install Angular JS first, since we are going to do all of our coding part using Angular JS.</p>
<div id="attachment_11326" style="width: 644px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages.png"><img decoding="async" aria-describedby="caption-attachment-11326" src="http://sibeeshpassion.com/wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-1024x416.png" alt="Install Angular JS From NuGet Packages" width="634" height="258" class="size-large wp-image-11326" srcset="/wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-1024x416.png 1024w, /wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-300x122.png 300w, /wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-768x312.png 768w, /wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-400x163.png 400w, /wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages-1477x600.png 1477w, /wp-content/uploads/2016/03/Install-Angular-JS-From-NuGet-Packages.png 1836w" sizes="(max-width: 634px) 100vw, 634px" /></a><p id="caption-attachment-11326" class="wp-caption-text">Install Angular JS From NuGet Packages</p></div>
<p>Now create a new page, start coding.</p>
<p><strong>Using The Code</strong></p>
<p>Before starting, we need to add the needed references to our page right?</p>
<p>[html]<br />
 &lt;script src=&quot;Scripts/angular.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/angular-aria.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/angular-route.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/myScripts.js&quot;&gt;&lt;/script&gt;<br />
[/html]</p>
<p>Here <em>myScripts.js&#8221;/em> is our JavaScript file where we are going to write out Angular JS scripts. Once you add the reference we will make some changes in our page as follows.</p>
<p>[html]<br />
&lt;!DOCTYPE html&gt;<br />
&lt;html ng-app=&quot;titApp&quot; ng-controller=&quot;titCtrl as t&quot;&gt;<br />
&lt;head&gt;<br />
    &lt;title&gt;{{t.title}} &#8211; Sibeesh Passion&lt;/title&gt;</p>
<p>    &lt;meta charset=&quot;utf-8&quot; /&gt;<br />
    &lt;script src=&quot;Scripts/angular.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/angular-aria.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/angular-route.min.js&quot;&gt;&lt;/script&gt;<br />
    &lt;script src=&quot;Scripts/myScripts.js&quot;&gt;&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
    &lt;h1&gt;{{t.title}}&lt;/h1&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>[/html]</p>
<p>As you can see <em>titApp</em> is our Angular JS app name and <em>titCtrl</em> is our controller name, now we will start writing the scripts. Are you ready?</p>
<p><em>Add Angular JS App</em></p>
<p>You can add an angular js app as follows.</p>
<p>[js]<br />
(function () {<br />
    var app;<br />
    app = angular.module(&#8216;titApp&#8217;, []);<br />
})();<br />
[/js]</p>
<p>Now we will create our controller.</p>
<p><em>Add Angular JS Controller</em></p>
<p>Below is our Angular JS controller scripts.</p>
<p>[js]<br />
app.controller(&#8216;titCtrl&#8217;, function ($scope, myFactory) {<br />
        var num = Math.floor(Math.random() * 6) + 1;<br />
        var newTit = [&#8216;Change Page Layout Dynamically Using jQuery Layout Plug in&#8217;, &#8216;February 2016 Month Winner In C-Sharp Corner&#8217;,<br />
        &#8216;Custom Deferred Grid Using MVC Web API And Angular JS&#8217;, &#8216;TagIt Control With Data From Database Using Angular JS In MVC Web API&#8217;,<br />
        &#8216;jQuery Datatable With Server Side Data&#8217;, &#8216;Programmatically Extract or Unzip Zip,Rar Files And Check&#8217;];<br />
        myFactory.setTitle(newTit[num]);<br />
        var tt = myFactory.getTitle();<br />
        if (tt != undefined) {<br />
            this.title = tt;<br />
        } else {<br />
            console.log(&#8216;Oops! Something went wrong while fetching the data.&#8217;);<br />
        }<br />
    });<br />
[/js]</p>
<p>Here <em>myFactory</em> is our Angular JS service name, and as you can see we have set an array with possible tiles in it already. We are generating one random number between 1 to 6 and take the appropriate value from the array by index. You can always load these data from a database instead. Here we uses two functions <em>setTitle</em> and <em>getTitle</em>, to set the title and get the title. Now we will see our Angular JS service scripts.  </p>
<p><em>Add Angular JS Service</em></p>
<p>[js]<br />
app.service(&#8216;myFactory&#8217;, function () {<br />
        var varTitle = &#8216;Change Title Dynamically Demo&#8217;;<br />
        this.getTitle = function () {<br />
            return varTitle;<br />
        };<br />
        this.setTitle = function (tit) {<br />
            varTitle = tit;<br />
        };<br />
    });<br />
[/js]</p>
<p>Now let us see the complete Angular JS scripts. </p>
<p><strong>Complete Scripts</strong></p>
<p>[js]<br />
(function () {<br />
    var app;<br />
    app = angular.module(&#8216;titApp&#8217;, []);<br />
    app.controller(&#8216;titCtrl&#8217;, function ($scope, myFactory) {<br />
        var num = Math.floor(Math.random() * 6) + 1;<br />
        var newTit = [&#8216;Change Page Layout Dynamically Using jQuery Layout Plug in&#8217;, &#8216;February 2016 Month Winner In C-Sharp Corner&#8217;,<br />
        &#8216;Custom Deferred Grid Using MVC Web API And Angular JS&#8217;, &#8216;TagIt Control With Data From Database Using Angular JS In MVC Web API&#8217;,<br />
        &#8216;jQuery Datatable With Server Side Data&#8217;, &#8216;Programmatically Extract or Unzip Zip,Rar Files And Check&#8217;];<br />
        myFactory.setTitle(newTit[num]);<br />
        var tt = myFactory.getTitle();<br />
        if (tt != undefined) {<br />
            this.title = tt;<br />
        } else {<br />
            console.log(&#8216;Oops! Something went wrong while fetching the data.&#8217;);<br />
        }<br />
    });<br />
    app.service(&#8216;myFactory&#8217;, function () {<br />
        var varTitle = &#8216;Change Title Dynamically Demo&#8217;;<br />
        this.getTitle = function () {<br />
            return varTitle;<br />
        };<br />
        this.setTitle = function (tit) {<br />
            varTitle = tit;<br />
        };<br />
    });<br />
})();<br />
[/js]</p>
<p>We have done everything needed, Now it is time to see the output.</p>
<p><strong>Output</strong></p>
<div id="attachment_11327" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output-e1456923830973.png"><img decoding="async" aria-describedby="caption-attachment-11327" src="http://sibeeshpassion.com/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output-e1456923830973.png" alt="Chnage_Page_Title_Dynamically_Using_Angular_JS_Output" width="650" height="289" class="size-full wp-image-11327" srcset="/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output-e1456923830973.png 650w, /wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output-e1456923830973-300x133.png 300w, /wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output-e1456923830973-400x178.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11327" class="wp-caption-text">Chnage_Page_Title_Dynamically_Using_Angular_JS_Output</p></div>
<div id="attachment_11328" style="width: 660px" class="wp-caption alignnone"><a href="http://sibeeshpassion.com/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927.png"><img decoding="async" aria-describedby="caption-attachment-11328" src="http://sibeeshpassion.com/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927.png" alt="Chnage_Page_Title_Dynamically_Using_Angular_JS_Output" width="650" height="340" class="size-full wp-image-11328" srcset="/wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927.png 650w, /wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927-300x157.png 300w, /wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927-600x315.png 600w, /wp-content/uploads/2016/03/Chnage_Page_Title_Dynamically_Using_Angular_JS_Output1-e1456923897927-400x209.png 400w" sizes="(max-width: 650px) 100vw, 650px" /></a><p id="caption-attachment-11328" class="wp-caption-text">Chnage_Page_Title_Dynamically_Using_Angular_JS_Output</p></div>
<p>Have a happy coding.</p>
<p><strong>Conclusion</strong></p>
<p>Did I miss anything that you may think which is needed? Have you ever wanted to do this requirement? Could you find this post as useful? I hope you liked this article. Please share me your valuable suggestions and feedback.</p>
<p><strong>Your turn. What do you think?</strong></p>
<p>A blog isn&#8217;t a blog without comments, but do try to stay on topic. If you have a question unrelated to this post, you’re better off posting it on C# Corner, Code Project, Stack Overflow, Asp.Net Forum instead of commenting here. Tweet or email me a link to your question there and I’ll definitely try to help if I can.</p>
<p>Kindest Regards<br />
Sibeesh Venu</p>
]]></content:encoded>
					
					<wfw:commentRss>https://mail.sibeeshpassion.com/change-the-page-title-dynamically-using-angular-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
