一,声名式注入

1:app.js:

var myApp = angular.module("myApp",["ngRoute"]);

2:controller.js:

myApp.controller("indexCtrl",['$scope',function($scope){              //如果想用混淆,必须使用中括号中声名注入参数

}])

3:config.js:

myApp.config(function($routeProvider, $locationProvider) {
    $routeProvider
    .when('/a', {
        templateUrl: 'web/templates/a.html',
        controller: 'aController'
    })
    .when('/b', {
        templateUrl: 'web/templates/b.html',
        controller: 'bController',
    .otherwise({
        redirectTo: '/a'
    });
});

二,直接注入

1:app.js

angular.moudle("myApp",[

  'ngRoute',

  'myApp.config',

'myApp.controllers'

]);

2:controllers.js

angular.module("myApp.controllers",[])  //如果想用混淆,必须使用中括号中声名注入参数

.controller("myCtrl",function($scope){

})

.controller("otherCtrl",function($scope){

})

3:config.js

angular.module("myApp.config",[])

.config(function($routeProvider, $locationProvider) {
    $routeProvider
    .when('/a', {
        templateUrl: 'web/templates/a.html',
        controller: 'aController'
    })
    .when('/b', {
        templateUrl: 'web/templates/b.html',
        controller: 'bController',
    .otherwise({
        redirectTo: '/a'
    });
});

angularJs模版注入的两种方式的更多相关文章

  1. Spring IOC 依赖注入的两种方式XML和注解

    依赖注入的原理 依赖注入的方式---XML配置 依赖注入的方式---注解的方式 Spring 它的核心就是IOC和AOP.而IOC中实现Bean注入的实现方式之一就是DI(依赖注入). 一 DI的原理 ...

  2. Python 防止mysql 注入的两种方式

    Python防止sql注入一般有两种方法 1.escape_string   MySQLdb.escape_string(param) 注意:如果报错出现 'ascii' codec can't en ...

  3. Spring 注入的两种方式

    Spring 的两种注入方式: 1. 属性注入:通过无参构造函数+setter方法注入 2. 构造注入:通过有参的构造函数注入. 优缺点: 1. 属性注入直白易懂,缺点是对于属性可选的时候,很多个构造 ...

  4. Spring基于注解注入的两种方式

    1.@Autowried 1)默认基于类型查找容器的的Bean进行注入(注入的Bean的实现类是唯一的). 2)当实现类的Bean大于一个的时候,需结合@Qualifier,根据Bean的名称来指定需 ...

  5. 实现mapper接口注入的两种方式,以及后台的使用区别

    1.使用模板方式: <!--使用模板类实现mybatis --> <bean id="sqlSession" class="org.mybatis.sp ...

  6. Spring自动注入,类型注入、名称注入(两种方式)

    参考: https://blog.csdn.net/qq_41767337/article/details/89002422 https://www.iteye.com/blog/breezylee- ...

  7. 预处理(防止sql注入的一种方式)

    <!--- 预处理(预编译) ---><?php/* 防止 sql 注入的两种方式: 1. 人为提高代码的逻辑性,使其变得更严谨,滴水不漏. 比如说 增加判断条件,增加输入过滤等,但 ...

  8. Spring中属性注入的几种方式以及复杂属性的注入

    在Spring框架中,属性的注入我们有多种方式,我们可以通过构造方法注入,可以通过set方法注入,也可以通过p名称空间注入,方式多种多样,对于复杂的数据类型比如对象.数组.List集合.map集合.P ...

  9. 【SSH进阶之路】Spring的IOC逐层深入——依赖注入的两种实现类型(四)

    上篇博文,我们介绍了为什么使用IOC容器,和IOC的设计思想以及IOC容器的优缺点,并且给大家转载了一篇介绍IOC原理的博文,我们这篇主要给大家依赖注入的两种方式,以及他们的优缺点. 我们这篇博文还是 ...

随机推荐

  1. Symmetry

    Description The figure shown on the left is left-right symmetric as it is possible to fold the sheet ...

  2. Linux学习笔记01

    1.Linux不靠扩展名区分文件类型2.存储设备必须先挂载才能使用3.Windows下的程序不能直接在Linux中安装和运行 一.服务器的管理预配置Linux的目录的作用:/bin/存放系统命令的目录 ...

  3. DNS域名服务器配置

    ========================DNS域名服务器===================== 1)bind安装: yum -y install bind* ............... ...

  4. 确定位置的经纬度LocationUtil

    package com.pingyijinren.test; import android.content.Context; import android.location.Location; imp ...

  5. KMP算法 C#实现 字符串查找简单实现

    KMP算法 的C#实现,初级版本 static void Main(string[] args) { #region 随机字符 StringBuilder sb = new StringBuilder ...

  6. Ajax核心知识(1)

    XMLHttpRequest对象创建 所有现代浏览器均支持XMLHttpRequest对象( IE5 和 IE6 使用 ActiveXObject). XMLHttpRequest用于在后台与服务器交 ...

  7. mysql 安装与卸载

    mysql用了也好几年了,但每次安装完或者卸载完就忘记了安装步骤以及卸载步骤,因此将关键的步骤记录下来,供以后参考. 1.mysql安装 ①安装类型有typical,complete,custom,一 ...

  8. javaweb开发页面数字过长显示科学计数法的问题

    1. 检查该字段是否为double类型,如果是,请改成BigDecimal 2.如果是导出excel里面为科学计数法,原页面正常,是因为excel设置的原因,请参考https://jingyan.ba ...

  9. 数据库可视化操纵软件有navicat和sqlyog

    数据库可视化操纵软件有navicat和sqlyog 数据库可视化操纵软件有navicat和sqlyog

  10. spring,spring mvc之所以起作用是因为开启了注解解释器,即spring的annotation on

    spring,spring mvc之所以起作用是因为开启了注解解释器,即spring的annotation on