将布尔值传入指令(Passing Boolean Value Into Directive)
我正在尝试使用
<div ngHide="readOnly">
切换指令呈现的元素的可见性。 值或readOnly
通过指令传入。angular.module('CrossReference') .directive('singleViewCard', [function() { return { restrict:'AE', templateUrl: '/CrossReference-portlet/js/templates/SingleViewCard.html', replace:true, scope: { readOnly:'@' }, link: { pre:function(scope, tElement, tAttrs) {}, post:function(scope, tElement, tAttrs) {}; } } }; }]);
这似乎在以下情况下工作:
<!-- element rendered in single-view-card is hidden --> <div single-view-card read-only="{{true}}"/> <!-- element rendered in single-view-card is shown --> <div single-view-card read-only="{{false}}"/>
但是,如果我反转布尔表达式
<div ngHide="!readOnly">
指令的下列用法不会像预期的那样隐藏潜水:<!-- element is rendered when it should be hidden --> <div single-view-card read-only="{{false}}"/>
我究竟做错了什么?
I am trying to toggle the visibility of an element rendered by a directive using
<div ngHide="readOnly">
. The value orreadOnly
is passed in via a directive.angular.module('CrossReference') .directive('singleViewCard', [function() { return { restrict:'AE', templateUrl: '/CrossReference-portlet/js/templates/SingleViewCard.html', replace:true, scope: { readOnly:'@' }, link: { pre:function(scope, tElement, tAttrs) {}, post:function(scope, tElement, tAttrs) {}; } } }; }]);
This seems to work in the following cases:
<!-- element rendered in single-view-card is hidden --> <div single-view-card read-only="{{true}}"/> <!-- element rendered in single-view-card is shown --> <div single-view-card read-only="{{false}}"/>
However, if I invert the boolean expression
<div ngHide="!readOnly">
The following usage of the directive does not hide the dive as expected:<!-- element is rendered when it should be hidden --> <div single-view-card read-only="{{false}}"/>
What am I doing wrong?
原文:https://stackoverflow.com/questions/25799363
更新时间:2023-10-03 08:10
最满意答案
其他回答
估计你使用了未导入的模块,你试一下简单点的代码,如下: try: f = open("file-not-exists", "r") except ioerror,e: print("open exception: %s: %s\n" %(e.errno, e.strerror))
相关问答
更多-
python3.4使用except提示no module[2023-09-01]
估计你使用了未导入的模块,你试一下简单点的代码,如下: try: f = open("file-not-exists", "r") except IOError,e: print("open exception: %s: %s\n" %(e.errno, e.strerror)) -
代码不起作用的原因是Sample类构造函数_init__中的一个简单错误而不是__init__ 。 修好后,一切都应该按预期工作。 编辑 处理程序方法应该只期望request参数,body可以从传递的request 。 def post_handler(self, request): payload = request._request_body.decode('utf-8') if not payload: return {'error': 'Payload not sup ...
-
写吧: sudo pip3 install Django 但更好地使用像丹尼尔说的virtualenv。 参考 如果您无法运行pip3,请使用以下命令安装它: sudo apt-get install python3-setuptools sudo easy_install3 pip Just write: sudo pip3 install Django But better use virtualenv like Daniel said. Reference If you cannot run ...
-
更改 sockobj.send(line) 至 sockobj.send(line.encode()) 在Python 3.x中, send工作在bytes而不是str 。 或者我们可以说,Python 3.x正确(我的意见)不再强制str -> bytes 。 Change sockobj.send(line) to sockobj.send(line.encode()) In Python 3.x send works on bytes not str. Or we could say, Pyt ...
-
Python的行为是从python2.7而不是python3.4运行(Python behave running from python2.7 rather than python3.4)[2023-02-26]
如果您安装了针对Python 3.x和Python 2.7的行为,则每个安装都将安装在/usr/local/bin/behave位置启动Behave的脚本。 无论最后安装哪个都将赢得冲突,因为它将覆盖另一个文件。 ( /usr/local/lib/python/dist-packages的文件没问题,因为 在每种情况下都不同。) 解决此问题的一种方法是解决仅在Python 3上安装Behave。卸载Python 2.7版本并重新安装Python 3版本,它应该可以工作。 如 ... -
您收到错误是因为您错误地使用了unittest 。 根据文档中的示例 ,您的测试应如下所示: import unittest class TestPrimes(unittest.TestCase): def test_singlePrime_returnsListContainingTwo(self): self.assertEqual(Primes.first(1), [2]) def test_whateverCase_expectedOutcome(self): ...
-
以root身份运行IDLE可能会有效,但它可能不是一个好主意。 sudo idle 选项1(推荐): 将需要提升权限的代码放在使用sudo运行的python文件中。 我假设您想要使用结果,因此您可以让脚本将结果保存到文件中,然后在IDLE中读取该文件。 以下代码适用于python 2.7和3.4 import nmap import json nm = nmap.PortScanner() nm.scan('192.168.5.1/24',arguments='-O') #Note that I test ...
-
我同样淹没了这个问题,这个流程在oracel-linux / python3中取得了成功 1.下载并安装sqlite3 $ tar sqlite-autoconf-3180000.tar.gz $ cd sqlite-autoconf-3180000 $./configure --prefix=/usr/local/sqlite3 && make && make install 2.Export LD_LIBRARY_PATH $ export LD_LIBRARY_PATH=/usr/local ...
-
用于python3.4的httpd mod_wsgi不能在centos7中工作(httpd mod_wsgi for python3.4 not working in centos7)[2023-09-02]
要让Python 3.4在CentOS中使用mod_wsgi,假设你从EPEL安装了Python 3.4(和pip),你可以这样做: yum install httpd-devel (你需要这个用于mod_wsgi的pip安装工作) pip3 install mod-wsgi mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf To get Python 3.4 working with mod_wsgi in C ... -
如何使用python3.4通过“https”登录页面登录?(How can I login through 'https' login page using python3.4?)[2022-06-16]
回溯的最后一行告诉你为什么: requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600) requests无法验证服务器的SSL证书。 您可以使用verify选项禁用证书验证: res = requests.post(loginURL, params=params, verify=False) 这样做有安全隐患,所以您是否应该这样做是您根据您的应用程序需求来决定 ...