在angular.js最常用的模块就是控制器了,通常我们会这样使用:

var myAppModule = angular.module('myApp', []);  

myAppModule.controller('TextController',  

    function($scope,$http) {  

     

        } );

这样就定义了一个新的控制器TextController,个人觉得不太习惯使用这种用法,我们 可以这样:

var TextController=function($scope){

    $scope.d="ddd";

}

实现相同功能!

angular controller的使用的更多相关文章

  1. angular controller as syntax vs scope

    今天要和大家分享的是angular从1.2版本开始带来了新语法Controller as.再次之前我们对于angular在view上的绑定都必须使用直接的scope对象,对于controller来说我 ...

  2. angular controller之间通信方式

    对于日常开发中,难免会有controller之间通信需求.对于controller之间通信有两种方式可以做到. 用 Angular 进行开发,基本上都会遇到 Controller 之间通信的问题,本文 ...

  3. angular controller 之间的通信方式

    AngularJS中的controller是个函数,用来向视图的作用域($scope)添加额外的功能,我们用它来给作用域对象设置初始状态,并添加自定义行为. 当我们在创建新的控制器时,angularJ ...

  4. angular controller的一些用法

    最近公司的项目是es6+angular.其中的代码格式还在逐步摸索中.感谢今天同事每天帮我解惑. 今天简单梳理一下controller的一些用法 之前看书所熟知的都是 这是最普通的一种 //html ...

  5. angular controller与directive相互引用

    /** * Created by Administrator on 2017/8/28. */ var app =angular.module('app',[]); app.directive('fo ...

  6. 33.AngularJS 应用 angular.module定义应用 angular.controller控制应用

    转自:https://www.cnblogs.com/best/tag/Angular/ AngularJS 模块(Module) 定义了 AngularJS 应用. AngularJS 控制器(Co ...

  7. 了解 : angular controller link ng-init 顺序

    controller 会先跑,接着是view 里的ng-init,最后是link (指令里的). 所有在指令里如果用link去拿$attr,会有拿不到ng-init想setup的值

  8. angular controller js 压缩后报错解决方案

    简单介绍下ng-annotate这个项目,这个项目正好提供了gulp的插件. gulp配置文件: var gulp = require('gulp'); var ngAnnotate = requir ...

  9. Angular select 绑定复杂类型 设置默认项

    <select ng-model="selectedTask" ng-options="s.name for s in TaskList">< ...

随机推荐

  1. python 进阶篇 函数装饰器和类装饰器

    函数装饰器 简单装饰器 def my_decorator(func): def wrapper(): print('wrapper of decorator') func() return wrapp ...

  2. python执行提示“ImportError: No module named OpenSSL.crypto”

    错误信息如下: Traceback (most recent call last): File "/usr/local/yunanbao/yxz-script/autoops/TaskSer ...

  3. vue中解决时间在ios上显示NAN的问题

    最近在用vue,遇到倒计时在ios上显示为NAN的问题. 因为做的是倒计时支付,思路是获取服务器时间和下单时间,再转成秒级时间戳做差值. 在网上找到说是ios 不支持例如2018-09-01 10:0 ...

  4. tensorflow1.0 矩阵相乘

    import tensorflow as tf matrix1 = tf.constant([[3,3]]) matrix2 = tf.constant([[2],[2]]) product = tf ...

  5. PHP中的数据库操作

    PDO project data object 连接到数据库 $db=new PDO("mysql:dbname=database;host=sever","userna ...

  6. HTML H5响应式,表格,表单等

    HTML杂项 响应式图片 <img srcset="elva-fairy-320w.jpg 320w, elva-fairy-480w.jpg 480w, elva-fairy-800 ...

  7. Java创建对象时的简单内存分析

    简单创建对象的内存分析 主程序: 1 public class Application { 2 public static void main(String[] args) { 3 Animal do ...

  8. Zookeeper之Error contacting service. It is probably not running.

    安装ZooKeeper时,无论是修改zoo.cfg:还是myid,都检查了几遍都没有错误.但是开启Zookeeper服务时出现: Error contacting service. It is pro ...

  9. Vue 2.x折腾记 - (17) 基于Ant Design Vue 封装一个配置式的表单组件

    前言 写了个类似上篇搜索的封装,但是要考虑的东西更多. 具体业务比展示的代码要复杂,篇幅太长就不引入了. 效果图 2019-04-25 添加了下拉多选的渲染,并搜索默认过滤文本而非值 简化了渲染的子组 ...

  10. H3C配置Web登陆

    为什么80%的码农都做不了架构师?>>>   1.开启http服务. [H3C]ip http enable 2.创建web登陆的用户. [H3C]local-user king / ...