在AngularJS中同一个页面配置一个或者多个ng-app
在AngularJS学习中,对于ng-app初始化一个AngularJS程序属性的使用需要注意,在一个页面中AngularJS自动加载第一个ng-app,其他ng-app会忽略,
如果需要加载其他ng-app程序,需要手动添加初始化过程。
手动初始化其他ng-app的javaScript代码 angular.bootstrap(document.getElementById("id"),['id']);
<div ng-app="myApp" ng-controller="myCtrl">
<input type="text" ng-model="first"/>
<input type="text" ng-model="last"/>
<br/>
姓名:{{ first + " " + last}}
</div> <div id="userForm" ng-app="userForm" ng-controller="userController">
<input type="text" ng-model="username"/><br/>
<input type="text" ng-model="password"/><br/>
用户名:{{username}}<br/>
密码: {{password}}
</div>
<script type="text/javascript">
var app = angular.module("myApp",[]);
app.controller("myCtrl",function($scope){
$scope.first = "test";
$scope.last = "test";
}); var userApp = angular.module("userForm",[]);
userApp.controller("userController",function($scope){
$scope.username = "test";
$scope.password = "test";
});
angular.bootstrap(document.getElementById("userForm"),['userForm']);
</script>
在AngularJS中同一个页面配置一个或者多个ng-app的更多相关文章
- angularjs中的页面访问权限设置
11月在赶一个项目,这阵子比较忙,挤挤时间更一篇博客吧,如标题所述说说在ng中页面访问权限控制的问题,水平有限各位看官见谅: 在以往的项目中,前后端常见的配合方式是前端提供页面和ui加一点DuangD ...
- 关于angularjs中路由页面强制更新的问题
有这么一个问题,在页面内路由页面跳转时,第一次跳入路由页面时是正常的,但是第二次会记住第一次时的状态,有时候并不想这样,想强制更新这个路由页面. 有一种方式就是使用 ui-sref-opts功能,我试 ...
- 项目中同一个页面引入不同的jQuery版本的不冲突问题
在写项目的过程中,如果需要使用jQuery时,时长会遇到需要引入不同版本的jQuery,可能上一个负责该项目的人用到的是老版本的jQuery,而你去添加功能时用的是新版本的,这个问题很难避免掉,如果去 ...
- AngularJS中移动页面滚动穿透解决方案
()] + s[]) >= , preventDefault: false, click: IscrollAndroidBug.click() }); var _ele = document.g ...
- angularJS中如何写控制器
angularJS中的控制器是一个函数,用来向视图作用域中添加额外的功能,我们用它来给作用域对象设置初始状态,并添加自定义行为 当我们在页面上创建一个新的控制器时,angularJS会生成并传递一个新 ...
- HTML5中与页面显示相关的API
1.HTML5中与页面显示相关的API 在HTML5中,增加了几个与页面显示相关的API,其中一个是Page Visibility API Page Visibility API 是指当页面变为最小 ...
- Angularjs中controller的三种写法
在Angular中,Directive.Service.Filter.Controller都是以工厂方法的方式给出,而工厂方法的参数名对应着该工厂方法依赖的Service.angularjs中cont ...
- angularjs中的directive scope配置
angularjs中的directive scope配置 定义directive其中重要的一环就是定义scope,scope有三种形式: 默认的scope,DOM元素上原有的scope scope: ...
- Web开发中错误页面的配置
一.创建错误处理页. 1)web.xml里面添加 <error-page> <error-code>404</error-code> <location> ...
随机推荐
- C#测试运行时间
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); //开始监视代码运行时间 ...
- idea使用心得(2)-安装设置与创建web项目
idea 是与eclipse齐名的IDE(集成开发工具),以智能闻名,不过对于熟悉eclipse的的用户来说,初次接触idea有些让人搞不清方向,下面介绍一下简单的使用 方式. 1.安装 官网下载ul ...
- LeetCode Coin Change
原题链接在这里:https://leetcode.com/problems/coin-change/ 题目: You are given coins of different denomination ...
- C++:C++的两种多态形式
// // main.cpp // Test.cpp // // Created by mac on 15/8/11. // Copyright (c) 2015年. All rights reser ...
- 使用intellij的svn时提示出错: Can't use Subversion command line client: svn.Errors found while svn working copies detection.
使用Intellij的svn时提示出错:Can't use Subversion command line client: svn. Errors found while svn working co ...
- new一張form時用using{}的好處。
以下代碼,用Using可避免一些問題,例如handel10000.如果PaymentForm裏面用dialogresult=''而不是close或X,(close或X會即時dispose回收,但dia ...
- ios10 xcode8 适配的那些事
1.首先open Url 废弃了. http://www.tuicool.com/articles/jiMr2qA
- lua 面向对象编程类机制实现
lua no class It is a prototype based language. 在此语言中没有class关键字来创建类. 现代ES6, 已经添加class类. prototype bas ...
- MWeb 1.3.7 发布!增加发布到 Wordpress 等支持 MetaWeblog API 的服务,如:Wordpress 博客、新浪博客、cnblogs、oschina。
MWeb 1.3.7 版的新功能 增加发布到 Wordpress 等支持 Metaweblog API 的服务,目前经测试过的有: Wordpress 博客.新浪博客.cnblogs.oschina. ...
- SSM框架-----------SpringMVC+Spring+Mybatis框架整合详细教程
1.基本概念 1.1.Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由Rod Johnson 在其著作Expert One-On-One ...