In this video we will discuss 2 simple but useful features in Angular

  • caseInsensitiveMatch
  • Inline Templates

Let us understand these 2 features with examples. 

caseInsensitiveMatch : The routes that are configured using config function are case sensitive by default. Consider the route below. Notice the route (/home) is lower case.

$routeProvider
    .when("/home", {
        templateUrl: "Templates/home.html",
        controller: "homeController",
        controllerAs: "homeCtrl",
    })
 

If we type the following URL in the browser, we will see home.html as expected.
http://localhost:51983/home

If you type the following URL, the you will see a blank layout page. This is because, by default routes are case-sensitive
http://localhost:51983/HOME

To make the route case-insensitive set caseInsensitiveMatch property to true as shown below.

$routeProvider
    .when("/home", {
        templateUrl: "Templates/home.html",
        controller: "homeController",
        controllerAs: "homeCtrl",
        caseInsensitiveMatch: true
    })
 

To make all routes case-insensitive set caseInsensitiveMatch property on $routeProvider as shown below.

$routeProvider.caseInsensitiveMatch = true; 

Inline Templates : The view content for the route (/home), is coming from a separate html file (home.html)

$routeProvider
    .when("/home", {
        templateUrl: "Templates/home.html",
        controller: "homeController",
        controllerAs: "homeCtrl",
    })

 

Should the view content always come from a separate html file. Not necessarily. You can also use an inline template. To use an inline template use template property as shown below.

$routeProvider
    .when("/home", {
        template: "<h1>Inline Template in action</h1>",
        controller: "homeController",
        controllerAs: "homeCtrl"
    })
 

At this point, when you navigate to http://localhost:51983/home, you should see Inline Template in action.

Part 35 AngularJS caseInsensitiveMatch and Inline Templates的更多相关文章

  1. 35.angularJS的ng-repeat指令

    转自:https://www.cnblogs.com/best/tag/Angular/ 1. <html> <head> <meta charset="utf ...

  2. angularjs编码实践

    AngularJS 是制作 SPA(单页面应用程序)和其它动态Web应用最广泛使用的框架之一.我认为程序员在使用AngularJS编码时有一个大的列表点应该记住,它会以这样或那样的方式帮助到你.下面是 ...

  3. AngularJs学习笔记--Understanding the Controller Component

    原版地址:http://docs.angularjs.org/guide/dev_guide.mvc.understanding_model 在angular中,controller是一个javasc ...

  4. [sinatra] Just Do It: Learn Sinatra, Part One Darren Jones

    1. Install sinatra gem gem install sinatra --no-ri --no-rdoc 2. Basic App #!/usr/bin/ruby require 's ...

  5. CodeForces 228D. Zigzag(线段树暴力)

    D. Zigzag time limit per test 3 seconds memory limit per test 256 megabytes input standard input out ...

  6. Luogu P5296 [北京省选集训2019]生成树计数

    Luogu P5296 [北京省选集训2019]生成树计数 题目链接 题目大意:给定每条边的边权.一颗生成树的权值为边权和的\(k\)次方.求出所有生成树的权值和. 我们列出答案的式子: 设\(E\) ...

  7. Elasticsearch 6.4基本操作 - Java版

    1. Elasticsearch Java API有四类client连接方式 TransportClient RestClient Jest Spring Data Elasticsearch 其中T ...

  8. SAMTOOLS使用 SAM BAM文件处理

    [怪毛匠子 整理] samtools学习及使用范例,以及官方文档详解 #第一步:把sam文件转换成bam文件,我们得到map.bam文件 system"samtools view -bS m ...

  9. ELK的sentinl告警配置详解

    背景 sentinl的监控&告警是通过watch实现的. 一.Watch Execution 执行开始的时候, watcher为watch创建watch执行上下文. 执行上下文提供脚本和模板, ...

随机推荐

  1. C++学习 3 结构体

    结构体基本概念: 结构体属于用户自定义的数据类型,允许用户存储不同的数据类型: 结构体定义和使用: 语法:struct 结构体名 { 结构体成员列表 }: 通过结构体创建变量名的方式有三种:     ...

  2. 时序数据库InfluxDB的基本语法

    一 了解InfluxDB的必要性 时序数据库主要存放的数据 Time series data is a series of data points each associated with a spe ...

  3. 题解 [AGC017C] Snuke and Spells

    题目传送门 Description 有 \(n\) 个球排在一起,每个球有颜色 \(a_i\),若当前有 \(k\) 个球,则会将所有 \(a_i=k\) 的球删掉.有 \(m\) 次查询,每次将 \ ...

  4. 题解 [HNOI/AHOI2018]毒瘤

    题目传送门 题目大意 给出一个 \(n\) 个点 \(m\) 条边的无向图,问有多少个点集满足点集中任意两点均不存在边相连. \(n\le 10^5,m-n\le 10\),答案对 \(9982443 ...

  5. 洛谷3203 弹飞绵羊(LCT)

    据说这个题当年的正解是分块qwq 根据题目所说,对于题目中的弹力系数,就相当于一条边,那么对于"跳出去"这个限制,我们可以选择建造一个新点\(n+1\)表示结束,那么每次,求一个点 ...

  6. CTF入门记录(1

    (https://ctf-wiki.org) 00 基础了解 CTF简介 (wolai.com) 00-1 CTF题目类型 Web 大部分情况下和网.Web.HTTP等相关技能有关. Web攻防的一些 ...

  7. HTML5背景知识

    目录 HTML5背景知识 HTML的历史 JavaScript出场 浏览器战争的结束 插件称雄 语义HTML浮出水面 发展态势:HTML标准滞后于其使用 HTML5简介 新标准 引入原生多媒体支持 引 ...

  8. 2020.4.6--UCF Local Programming Contest 2017的正式赛

    Problem A : Electric Bill 题目大意:进行电量分级制收费,1000kwh及以下一档收费,1000kwh以上按另一档收费,给出每个人的电量总额,问每人应支付多少钱. 思路:基础i ...

  9. python中的load、loads实现反序列化

    load与loads 简介: 在python自动化中,我们传递一些参数是需要从文件中读取过来的,读取过来的字典并非python对象数据类型而是string类型. 这样在我们传递参数的时候就会出现格式不 ...

  10. DL4J实战之六:图形化展示训练过程

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 本篇是<DL4J实战>系列的第六 ...