angular.element(document.querySelector('[ng-controller=mainCtrl]')).scope().viewGo('tab.VIPPay_Success',{})

<!DOCTYPE html>
<html ng-app="myApp" id="myApp">
<head>
<meta name="viewport" content="width=device-width" />
<title>Test</title>
<script src="~/Content/Js/Plugins/AngularJS/angular.min.js"></script>
</head>
<body ng-controller="myController">
{{msg}}
<a href="javascript:;" id="lbtnTest">调用</a>
</body>
</html>
<script>
var ngApp = angular.module('myApp', []);
ngApp.controller('myController', function ($scope, $http) {
$scope.msg = '你好,Angular!';
$scope.getData = function () {
return 'qubernet';
}
});
onload = function () {
document.getElementById('lbtnTest').onclick = function () {
//通过controller来获取Angular应用
var appElement = document.querySelector('[ng-controller=myController]');
//获取$scope变量
var $scope = angular.element(appElement).scope();
//调用msg变量,并改变msg的值
$scope.msg = '123456';
//上一行改变了msg的值,如果想同步到Angular控制器中,则需要调用$apply()方法即可
$scope.$apply();
//调用控制器中的getData()方法
console.log($scope.getData());
}
}
</script>

  http://www.jb51.net/article/89939.htm

angularjs 外部调用controller中的方法的更多相关文章

  1. Spring的Aspect切面类不能拦截Controller中的方法

    根本原因在于<aop:aspectj-autoproxy />这句话是在spring的配置文件内,还是在springmvc的配置文件内.如果是在spring的配置文件内,则@Control ...

  2. ASP.NET MVC4在View中调用当前Controller中的方法

    调用当前Controller中的方法 @{ ((HomeController)ViewContext.Controller).Method1(); } 调用静态方法 @{ SomeClass.Meth ...

  3. Spring AOP无法拦截Controller中的方法

    想使用AOP Annotation配置Spring MVC的Controller进行拦截, 发现无法拦截Controller的方法, 却可以拦截Service层的方法. 一开始: Spring的配置文 ...

  4. spring MVC controller中的方法跳转到另外controller中的某个method的方法

    1. 需求背景     需求:spring MVC框架controller间跳转,需重定向.有几种情况:不带参数跳转,带参数拼接url形式跳转,带参数不拼接参数跳转,页面也能显示. 本来以为挺简单的一 ...

  5. spingAOP在springMVC中的使用(我用在拦截controller中的方法。主要用于登录控制)

    首先截取了网上的一张配置execution的图片 我在项目中关于aop的配置:如果拦截controller的方法,需要在spring-mvc.xml文件中加入(如果在spring.xml中加入则无法拦 ...

  6. 反射找Controller中的方法

    /// <summary> /// 根据接口编码APICode,调用相应的webapi方法,注意返回值是json字符串 /// </summary> /// <param ...

  7. SpringMVC controller中业务方法的参数、返回值

    业务方法的参数 业务方法的参数类型.参数个数是任意的,根据需要使用. 常见的参数类型: HttpServletRequest.HttpServletResponse.HttpSession    获取 ...

  8. [.NET WebAPI系列03] WebAPI Controller 中标准CRUD方法

    [因] WebAPI的Controller中,一般都是下面四种方法: 对应于数据操作是我们通常所说的CRUD. C对应post,R对应Get,U对应Put,D对应Delete. 直接模仿VS 2012 ...

  9. Spring拦截器中通过request获取到该请求对应Controller中的method对象

    背景:项目使用Spring 3.1.0.RELEASE,从dao到Controller层全部是基于注解配置.我的需求是想在自定义的Spring拦截器中通过request获取到该请求对应于Control ...

随机推荐

  1. idea创建maven spring项目,出现的问题

    1.jetty启动后,明明配置文件配置的是 <plugin> <groupId>org.eclipse.jetty</groupId> <artifactId ...

  2. 微软Power BI 每月功能更新系列——9月Power BI 新功能学习

    Power BI Desktop 9月新功能摘要 Power BI 9月更新如期而至,这一次Power BI 又推出了新功能——聚合预览,它可在内存中无缝地存储汇总值,大大提高报告的性能.另外本月还包 ...

  3. [转]Deep Reinforcement Learning Based Trading Application at JP Morgan Chase

    Deep Reinforcement Learning Based Trading Application at JP Morgan Chase https://medium.com/@ranko.m ...

  4. CentOS 使用 yum 更新软件包与系统

    1.CentOS 更新源配置文件说明 CentOS 6.5 更新源配置文件 /etc/yum.repos.d/CentOS-Base.repo 片段 [base] name=CentOS-$relea ...

  5. Redis持久化--RDB+AOF(转)

    1.Redis两种持久化方式 RDB 执行机制:快照,直接将databases中的key-value的二进制形式存储在了rdb文件中 优点:性能较高(因为是快照,且执行频率比aof低,而且rdb文件中 ...

  6. php算法面试案例(转)

    有5个人偷了一堆苹果,准备在第二天分赃.晚上,有一人遛出来,把所有菜果分成5份,但是多了一个,顺手把这个扔给树上的猴了,自己先拿1/5藏了.没想到其他四人也都是这么想的,都如第一个人一样分成5份把多的 ...

  7. apache php upload file

    /********************************************************************************* * apache php uplo ...

  8. c# 休眠后 定时唤醒

    源码见附件,执行唤醒功能前需要先对电源进行设置如下图: 源码

  9. 2018.4.23 git命令总结

    git clone git pull git add xx git add . git add -A git branch 查看本地分支 git branch --all 查看所有分支 git bra ...

  10. Linux 进程管理 笔记

    https://www.ibm.com/developerworks/cn/linux/l-linux-process-management/index.htmlLinux 进程管理剖析 进程可以是短 ...