ng-如果不使用简单的javascript(ng-if not working with simple javascript)
当我通过简单的javascript函数更改值时,ng-if不起作用。我的函数被调用但是在视图中看不到值的更改。 请参考以下代码。
HTML
<div id="span" ng-app='MyModule' ng-cloak ng-controller="MyController"> <div ng-if="!bool"> This is for true </div> <div ng-if="bool"> This is False </div> {{bool}} <br> <input type="submit" ng-click = "myfunction('test')" value="ng-if button"> </div> <input type="submit" onClick = "check1()" value="simple JS button">
JS
angular.module('MyModule', []) .controller('MyController', function ($scope) { $scope.bool = true; $scope.myfunction = function (data) { $scope.bool = !$scope.bool; }; }); function check1() { angular.element(document.getElementById('span')).scope().myfunction('test'); }
当我使用
ng-click button
它会改变bool
变化的值,但是simple JS button
不会发生同样的情况。 实际上我在已经使用jQuery的页面中实现Angular,所以我需要使用simple JS button
。JS小提琴 : JS小提琴
ng-if is not working when I change the values through simple javascript function.My function is getting called but the changes in values cannot be seen in view. Please refer below code.
HTML
<div id="span" ng-app='MyModule' ng-cloak ng-controller="MyController"> <div ng-if="!bool"> This is for true </div> <div ng-if="bool"> This is False </div> {{bool}} <br> <input type="submit" ng-click = "myfunction('test')" value="ng-if button"> </div> <input type="submit" onClick = "check1()" value="simple JS button">
JS
angular.module('MyModule', []) .controller('MyController', function ($scope) { $scope.bool = true; $scope.myfunction = function (data) { $scope.bool = !$scope.bool; }; }); function check1() { angular.element(document.getElementById('span')).scope().myfunction('test'); }
When I use
ng-click button
it changes value ofbool
changes, but same doesn't happens withsimple JS button
. Actually I am implementing Angular in a page that already uses jQuery, so I need to usesimple JS button
.JS Fiddle : JS Fiddle
原文:https://stackoverflow.com/questions/43142237
满意答案
在您自己的SAS代码中,您使用宏变量
username
,但在您的存储过程中,用户名在保留的宏变量_username
。 下划线实际上是变量名的一部分,所以你应该写&_username
。有关更多信息,您可以阅读文档或在插入后查阅日志
%put _automatic_;
在您的代码中,打印所有为您提供的宏变量SAS。
备注:由于存储过程中的自动宏变量与本地SAS会话中的自动宏变量不同,如果要在两者中使用相同的代码,则通常需要一些
%if %then %else
逻辑。In your own SAS code, you use a macro variable
username
, but in your stored process, the user name is available in the reserved macro variable_username
. The underscore is really part of the variable name, so you should write&_username
.For more information, you can read the documentation or you can consult the log after inserting
%put _automatic_;
in your code, to print all macro variables SAS provided for you.
Remark: As the automatic macro variables in a stored process differ from that in a local SAS session, if you want to use the same code in both, you often need some
%if %then %else
logic.
相关问答
更多SAS将分钟添加到存储在宏变量中的时间戳(SAS Adding Minutes to a Timestamp Stored in a Macro Variable)
SAS存储过程的XML语法(XML Syntax for SAS Stored Process)
修改SAS中宏变量的值(Modifying the value of macro variable in SAS)
如何处理SAS存储过程中的多个过滤器(How to handle multiple filters in SAS stored process)
获取SAS表中的宏变量值(Get values of Macro Variables in a SAS Table)
将数值表达式的结果存储在SAS宏变量中(Store result of numeric expression in SAS macro variable)
sas存储过程中的宏变量(Macro variable in sas stored process)
如何在Excel中键入SAS提示值以运行存储过程?(How to type SAS prompt value in Excel to run stored process?)
SAS将字符表示存储在宏变量中的日期上(SAS store the character representation on a date in a macro variable)
使用硬编码证书绕过STP登录屏幕 - 从Web执行SAS存储过程(Bypass STP Login Screen Using Hard-Coded Credentials - Execute SAS Stored Process from Web)
相关文章
更多javascript 问题
javascript的验证
请教javascript问题
javascript 基本语法
JavaScript 事件
JavaScript 事件
Working on Free Software
javascript url编码
javascript常用对象
最新问答
更多python的访问器方法有哪些
使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
透明度错误IE11(Transparency bug IE11)
linux的基本操作命令。。。
响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements)
它看起来像只在Windows上的Chrome的错误。 我在Google Canary (Chrome 63)中也进行了测试,问题依然存在,所以有可能它不会很快修复。 这个问题是由overflow: auto引起的overflow: auto ,在你的情况下,它可以很容易地通过删除或设置为可见(默认)来解决。 但是 ,将鼠标悬停在右侧(顶部和底部)时,会出现滚动条。 一个解决方案可以设置overflow: hidden的身体,所以预期的结果是所需的。 我想指出,这不是一个很好的解决方案,但我建议暂
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
这取决于您是否要以后与用户合作,或仅检查是否存在。 如果要使用用户对象(如果存在): $user = User::where('email', '=', Input::get('email'))->first(); if ($user === null) { // user doesn't exist } 如果你只想检查 if (User::where('email', '=', Input::get('email'))->count() > 0) { // user found
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
$scope.getData= function () { var reader = new FileReader(); reader.onload = $('input[type=file]')[0].files; var img = new Image(); img.src =(reader.onload[0].result); img.onload = function() { if(this.width > 640
Copyright ©2023
peixunduo.com All
Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!
Laravel检查是否存在记录(Laravel Checking If a Record Exists)
设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!