<?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>Javascript Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/category/web/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/category/web/javascript/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 05 May 2022 11:31:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Handling not found routes in Angular</title>
		<link>https://blogit.create.pt/pedrolopes/2022/05/05/handling-not-found-routes-in-angular/</link>
					<comments>https://blogit.create.pt/pedrolopes/2022/05/05/handling-not-found-routes-in-angular/#respond</comments>
		
		<dc:creator><![CDATA[Pedro Lopes]]></dc:creator>
		<pubDate>Thu, 05 May 2022 11:31:15 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[404]]></category>
		<guid isPermaLink="false">https://blogit.create.pt/?p=12669</guid>

					<description><![CDATA[<p>In this post, we will see how we can handle 404 routes using a not found component in an Angular. There are two types of 404 routes that we want to handle. Static 404 &#8211; the URL the user navigates to doesn&#8217;t match any route Dynamic 404 &#8211; the URL matches a route, but the [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/pedrolopes/2022/05/05/handling-not-found-routes-in-angular/">Handling not found routes in Angular</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this post, we will see how we can handle 404 routes using a not found component in an Angular.</p>



<p>There are two types of 404 routes that we want to handle.</p>



<ul class="wp-block-list"><li><strong>Static 404</strong> &#8211; the URL the user navigates to doesn&#8217;t match any route</li><li><strong>Dynamic 404</strong> &#8211; the URL matches a route, but the data associated with that route does not exist. For example, you navigate to a detail page with an ID, but no item exists with that ID.</li></ul>



<p>For this post, I assume that there is a component named <code>NotFoundComponent</code> that is the not found page to show the user. Replace this with whatever component</p>



<h2 class="wp-block-heading">Static 404 routes</h2>



<p>To set up a static 404 page, you need to add two routes to your <code>RoutingModule</code> configuration.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
const routes: Routes = &#x5B;
    // Other routes
    { path: &#039;404&#039;, component: NotFoundComponent },
    { path: &#039;**&#039;, component: NotFoundComponent }
]
</pre></div>


<p>We used a catchall route <code><em>'</em>**'</code> that matches whatever route didn&#8217;t match above, and shows our not found page.</p>



<p>Make sure to keep the catchall route at the end of your routes, otherwise the routes below it will not be accessible.</p>



<p>Another option here would&#8217;ve been to redirect the user to the <code>'404'</code> route, but that way you lose the context of the URL. If the user navigates back, he would go to the non-existing route and be redirected to the <code>'404'</code> path again. If this is the behavior you want, switch the last route with <code>{ path: '**', redirectTo: '404' }</code>.</p>



<h2 class="wp-block-heading">Dynamic 404 routes</h2>



<p>Now that we have the static 404 route configured, we can use the router to navigate to it whenever we want to show the not found page to the user.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
this.router.navigate(&#x5B;&#039;/404&#039;], { skipLocationChange: true });
</pre></div>


<p>By using the option <code>skipLocationChange: true</code>, we have the same behavior as mentioned above. Even though the router navigates to the route, the browser URL stays the same, allowing the user to easily go back.</p>



<h3 class="wp-block-heading">Personalizing the 404 message</h3>



<p>You may want to personalize the message shown on the 404 page. One way to do this is using the navigation state.</p>



<p>When navigating to the 404 page, you can include a <code>state</code> in the navigation options.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
this.router.navigate(&#x5B;&#039;/404&#039;], { 
    skipLocationChange: true,
    state: {
        // Whatever data you need on the 404 page
    	source: &#039;article&#039;,
        id: 123456
    }
});
</pre></div>


<p>On your <code>NotFoundComponent</code>, you can access this object in the constructor using the router&#8217;s <a href="https://angular.io/api/router/Router#getcurrentnavigation"><code>getCurrentNavigation</code></a> method.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: jscript; title: ; notranslate">
export class NotFoundComponent {
  constructor(private router: Router) {
    console.log(this.router.getCurrentNavigation().extras.state.source);
  }
}
</pre></div>


<p>You must access the state in the constructor, as it is only available while the router is navigating.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>In this post, we saw how to implement a 404 route in Angular. We looked at how we can redirect to it dynamically and even how to personalize the 404 page with route dependent data!</p>



<p>Have questions, corrections, or an alternative way of handling this? Leave a comment or reach out to me on Twitter <a href="https://twitter.com/pedronavelopes">@pedronavelopes</a> and let me know! Thanks for reading!</p>
<p>The post <a href="https://blogit.create.pt/pedrolopes/2022/05/05/handling-not-found-routes-in-angular/">Handling not found routes in Angular</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/pedrolopes/2022/05/05/handling-not-found-routes-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Adding an Angular app to your Umbraco Website</title>
		<link>https://blogit.create.pt/marionunes/2018/03/10/adding-an-angular-app-to-your-umbraco-website/</link>
					<comments>https://blogit.create.pt/marionunes/2018/03/10/adding-an-angular-app-to-your-umbraco-website/#comments</comments>
		
		<dc:creator><![CDATA[Mário Nunes]]></dc:creator>
		<pubDate>Sat, 10 Mar 2018 22:11:23 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Umbraco]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[.NET]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/marionunes/?p=334</guid>

					<description><![CDATA[<p>What problems does this solve? This enables you to have an Angular application alongside your Umbraco website, on a specified route. The Angular App can be protected by the Authentication of your website, if you have it. And you can make use of surface controllers for authenticated requests. The routing of your app will work [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/marionunes/2018/03/10/adding-an-angular-app-to-your-umbraco-website/">Adding an Angular app to your Umbraco Website</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><strong>What problems does this solve?</strong></p>
<ul>
<li>This enables you to have an Angular application alongside your Umbraco website, on a specified route.</li>
<li>The Angular App can be protected by the Authentication of your website, if you have it. And you can make use of surface controllers for authenticated requests.</li>
<li>The routing of your app will work as intended, for example, if your Angular app is at <strong>/app</strong> and you make a request to <strong>/app/products</strong>, the request will be routed to the angular app products&#8217; page.</li>
</ul>
<p><strong>What this is not</strong></p>
<ul>
<li>A complete front end for a Umbraco website with dynamic routes.</li>
<li>This doesn&#8217;t have dynamic routes, you have to specify them on your code.</li>
</ul>
<p><strong>Let&#8217;s get started!</strong></p>
<p>First, start by creating a controller to handle the Angular App request.</p>
<pre class="brush: csharp; title: ; notranslate">
using System.Web.Mvc;

public class AngularAppController : BaseController
{
    public ActionResult AngularAppView()
    {
        return View();
    }
}
</pre>
<p>Then, you have to decide the route where your Angular app will render. On this example it will be <strong>/angularapp</strong>.</p>
<p>On your ApplicationStarted method, put this code:</p>
<pre class="brush: csharp; title: ; notranslate">
RouteTable.Routes.MapRoute(
  &quot;AngularApp&quot;,
  &quot;angularapp/{*.}&quot;,
  new { controller = &quot;AngularApp&quot;, action = &quot;AngularAppView&quot; });
</pre>
<p>The <strong>{*.}</strong> syntax is what makes your angular app routes load and not return the 404 page.</p>
<p>If you don&#8217;t have an ApplicationStarted method, find out how you to create it here: <a href="https://our.umbraco.org/documentation/reference/events/application-startup">https://our.umbraco.org/documentation/reference/events/application-startup</a></p>
<p>Under your Views folder, create a folder with the same name as the <strong>controller</strong> you set in MapRoute. In this case it will be &#8220;AngularApp&#8221;.<br />
Inside it, create a view with the same name as the <strong>action</strong> set you set in MapRoute.<br />
<img decoding="async" src="http://blogit-create.com/wp-content/uploads/2018/03/appview.png" alt="" width="268" height="71" class="alignnone size-full wp-image-414" srcset="https://blogit.create.pt/wp-content/uploads/2018/03/appview.png 268w, https://blogit.create.pt/wp-content/uploads/2018/03/appview-265x71.png 265w" sizes="(max-width: 268px) 100vw, 268px" /></p>
<p>Inside the view put the contents of the index.html of your angular app.<br />
Then you will need to move your angular app files somewhere like you /Assets folder, and edit their paths on the view.</p>
<p>Almost done!</p>
<p>Now you need to edit the routes of your Angular app.<br />
Simply add the route you chose as a prefix to the routes.</p>
<p>From something like this:</p>
<pre class="brush: csharp; title: ; notranslate">
const routes: Routes = &#x5B;
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' },
  { path: '/dashboard', component: DashboardComponent },
  { path: '/detail/:id', component: HeroDetailComponent },
  { path: '/heroes', component: HeroesComponent }
];
</pre>
<p>To this:</p>
<pre class="brush: csharp; title: ; notranslate">
const routes: Routes = &#x5B;
  { path: 'angularapp', redirectTo: 'angularapp/dashboard', pathMatch: 'full' },
  { path: 'angularapp/dashboard', component: DashboardComponent },
  { path: 'angularapp/detail/:id', component: HeroDetailComponent },
  { path: 'angularapp/heroes', component: HeroesComponent }
];
</pre>
<p>Thanks for reading!<br />
Mário</p>
<p>The post <a href="https://blogit.create.pt/marionunes/2018/03/10/adding-an-angular-app-to-your-umbraco-website/">Adding an Angular app to your Umbraco Website</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/marionunes/2018/03/10/adding-an-angular-app-to-your-umbraco-website/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>Microsoft WebCamp 2014: Working with AngularJS</title>
		<link>https://blogit.create.pt/andrevala/2014/05/25/microsoft-webcamp-2014-working-with-angularjs/</link>
					<comments>https://blogit.create.pt/andrevala/2014/05/25/microsoft-webcamp-2014-working-with-angularjs/#respond</comments>
		
		<dc:creator><![CDATA[André Vala]]></dc:creator>
		<pubDate>Sun, 25 May 2014 19:29:41 +0000</pubDate>
				<category><![CDATA[AngularJS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">http://blogcreate.azurewebsites.net/andrevala/?p=41</guid>

					<description><![CDATA[<p>Last week I delivered a session at Microsoft WebCamp 2014 event. A full-day event, with 3 simultaneous session tracks, focused on web technologies, not only from Microsoft but also open source, and design/communication topics. A lot of good stuff was shown, from node.js to service stack. My session was about Working with AngularJS, a fantastic [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/andrevala/2014/05/25/microsoft-webcamp-2014-working-with-angularjs/">Microsoft WebCamp 2014: Working with AngularJS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Last week I delivered a session at <strong>Microsoft WebCamp 2014</strong> event. A full-day event, with 3 simultaneous session tracks, focused on web technologies, not only from Microsoft but also open source, and design/communication topics. A lot of good stuff was shown, from node.js to service stack.</p>
<p>My session was about <strong>Working with AngularJS</strong>, a fantastic Single Page Application framework in JavaScript. It’s an introductory session, meant to give attendees a basic understanding of the framework and its components. I had a packed room, with around 200 people, and the feedback was great so I felt it might be worth sharing the slides and demos I wrote for the session:</p>
<ul>
<li><a href="http://1drv.ms/1h1YOlS" target="_blank">Slides</a> (on OneDrive)</li>
<li><a href="http://www.slideshare.net/AndreVala/working-with-angularjs" target="_blank">Slides</a> (on SlideShare)</li>
<li><a href="http://1drv.ms/1h1YJyP" target="_blank">Demos</a> (on OneDrive)</li>
</ul>
<p>You’re probably wondering why would I, a SharePoint guy, be talking about <a href="http://angularjs.org" target="_blank">AngularJS</a>. SharePoint guys are not exactly known for embracing the latest and greatest web technologies, mostly because when a new SharePoint version is released, it’s already one .Net version behind, not to mention all the new JavaScript frameworks. With SharePoint 2013, all that is changed. The new <a href="http://msdn.microsoft.com/en-US/office/dn448479" target="_blank">SharePoint App Model</a> allows us to build our apps in any technology we want, and that means we can use all the big boys toys now such as ASP.NET MVC and, of course, AngularJS.</p>
<p>Also presenting a session on WebCamp about <a href="http://knockoutjs.com/" target="_blank">KnockoutJS</a> was my good friend and colleague <a href="http://blogit.create.pt/blogs/joaomartins" target="_blank">João “Jota” Martins</a>, which is a great JavaScript data-binding library. Although they share some concepts, Knockout and Angular are very different technologies, on very different abstraction levels, so it’s good to know when to use one or the other. Checkout his slides and code samples <a href="http://blogit.create.pt/blogs/joaomartins/archive/2014/05/22/Microsoft-WebCamp-20.05.2014_1320_Databinding-with-KnockoutJS.aspx" target="_blank">here</a>.</p>
<p>The post <a href="https://blogit.create.pt/andrevala/2014/05/25/microsoft-webcamp-2014-working-with-angularjs/">Microsoft WebCamp 2014: Working with AngularJS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/andrevala/2014/05/25/microsoft-webcamp-2014-working-with-angularjs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Microsoft WebCamp 20.05.2014–Databinding with KnockoutJS</title>
		<link>https://blogit.create.pt/jota/2014/05/22/microsoft-webcamp-20-05-2014-databinding-with-knockoutjs/</link>
					<comments>https://blogit.create.pt/jota/2014/05/22/microsoft-webcamp-20-05-2014-databinding-with-knockoutjs/#respond</comments>
		
		<dc:creator><![CDATA[Jota]]></dc:creator>
		<pubDate>Thu, 22 May 2014 10:49:56 +0000</pubDate>
				<category><![CDATA[KnockoutJS]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">http://blogcreate.azurewebsites.net/joaomartins/?p=81</guid>

					<description><![CDATA[<p>Earlier this week I did a presentation at Microsoft WebCamp 2014, a 3-track event focused on Microsoft web technologies, open source web libraries, and design/communication trends and tendencies. The session as a level ~250-300 session on KnockoutJS, Steven Sanderson’s et al. data-binding Javascript framework. Earlier, my colleague and friend André “SharePoint God” Vala did a [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/jota/2014/05/22/microsoft-webcamp-20-05-2014-databinding-with-knockoutjs/">Microsoft WebCamp 20.05.2014–Databinding with KnockoutJS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Earlier this week I did a presentation at <strong>Microsoft WebCamp 2014</strong>, a 3-track event focused on Microsoft web technologies, open source web libraries, and design/communication trends and tendencies. The session as a level ~250-300 session on <a href="http://knockoutjs.com/" target="_blank">KnockoutJS</a>, Steven Sanderson’s et al. data-binding Javascript framework.</p>
<p>Earlier, my colleague and friend <a href="http://blogit.create.pt/blogs/andrevala/" target="_blank">André “SharePoint God” Vala</a> did a session on <a href="https://angularjs.org/" target="_blank">AngularJS</a>, so we got to share information on two libraries with very different levels of abstraction for web development. Had about 70-80 people in the room, in what was session with more code samples I’ve done for some time now.</p>
<p>You can download the slides <a href="https://onedrive.live.com/redir?resid=8EE85D8713522EC1!13965&amp;authkey=!ANJJ79CiJEBis20&amp;ithint=file%2c.zip" target="_blank">here</a> or check them on <a href="http://www.slideshare.net/slidejota/20140520-microsoft-webcamp-databinding-with-knockoutjs" target="_blank">Slideshare</a>, and the code samples are <a href="https://onedrive.live.com/redir?resid=8EE85D8713522EC1%2113964" target="_blank">here</a>.</p>
<p>The post <a href="https://blogit.create.pt/jota/2014/05/22/microsoft-webcamp-20-05-2014-databinding-with-knockoutjs/">Microsoft WebCamp 20.05.2014–Databinding with KnockoutJS</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/jota/2014/05/22/microsoft-webcamp-20-05-2014-databinding-with-knockoutjs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JavaScript Debugging</title>
		<link>https://blogit.create.pt/saraoliveira/2009/03/26/javascript-debugging/</link>
					<comments>https://blogit.create.pt/saraoliveira/2009/03/26/javascript-debugging/#respond</comments>
		
		<dc:creator><![CDATA[Sara Oliveira]]></dc:creator>
		<pubDate>Thu, 26 Mar 2009 15:05:00 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web]]></category>
		<guid isPermaLink="false">http://blogcreate.azurewebsites.net/saraoliveira/?p=31</guid>

					<description><![CDATA[<p>Have you ever wish to debug your javascript code? Well, it&#8217;s possible and easy to do. You just have to add the line debugger; where you want the breakpoint to stop and ensure that the &#8220;disable javascript&#8221; option in your Internet Options is not checked.</p>
<p>The post <a href="https://blogit.create.pt/saraoliveira/2009/03/26/javascript-debugging/">JavaScript Debugging</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Have you ever wish to debug your javascript code?</p>
<p>Well, it&#8217;s possible and easy to do.</p>
<p>You just have to add the line</p>
<p><strong>debugger;</strong></p>
<p>where you want the breakpoint to stop and ensure that the &#8220;disable javascript&#8221; option in your Internet Options is <strong>not</strong> checked.</p>
<p>The post <a href="https://blogit.create.pt/saraoliveira/2009/03/26/javascript-debugging/">JavaScript Debugging</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/saraoliveira/2009/03/26/javascript-debugging/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
