我有一个 MatDialog,它在构造时由其父级提供了一个 HTML 字符串。HTML 字符串是命名 div 内容的来源,并且包含<table>嵌入 html 中的标签,但由于某种原因,对话框的 scss 文件中定义的表格样式不适用于我指定为 的字符串[innerHTML],尽管它对于<table>标签来说效果很好直接硬编码到html文件中。
有什么方法可以让对话框使用对话框组件的样式模板中包含的样式来渲染innerHTML?
export class DialogAgreementViewer implements AfterViewInit {
constructor(public dialogRef:
MatDialogRef<DialogAgreementViewer>, @Inject
(MAT_DIALOG_DATA) public data: string, protected _sanitizer : DomSanitizer){
this.agreementText = this._sanitizer.bypassSecurityTrustHtml(data);
}
public agreementText : SafeHtml;
@ViewChild('agreementText') agreementTextCtl : ElementRef;
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<p>Agreement Template</p>
<table>. <-- Defined table styles are applied to this table.
<tbody>
<tr><td>Title</td><td>Name of Work</td></tr>
</tbody>
</table>
<div [innerHTML]='agreementText'></div> <-- Table styles not applied here.
Run Code Online (Sandbox Code Playgroud)
社会保障体系:
table, td …Run Code Online (Sandbox Code Playgroud) 来自JUnit背景我不太了解spockD测试中所有文本的要点,因为它们没有显示在测试的输出上.
因此,例如,如果我对具有约束foo max:5的字段Double foo有约束,则nullable:false
我写这样的测试:
void "test constraints" {
when: "foo set to > max"
foo=6D
then: "max validation fails"
!foo.validate()
when: "foo is null
foo=null
then: "null validation fails"
!foo.validate()
}
Run Code Online (Sandbox Code Playgroud)
该测试在其源代码中有详细记录,但如果验证失败,则错误输出不会利用我所做的所有额外输入以使我的测试清晰.
我得到的只是
Failure: |
test constraints(com.grapevine.FooSpec)
|
Condition not satisfied:
f.validate()
| |
| false
Run Code Online (Sandbox Code Playgroud)
但我无法告诉表单这个报告是否未通过空约束或最大约束验证,然后我需要检查测试源中失败的行号.
至少我可以做JUnit
foo=60D;
assertFalse("contraints failed to block foo>max", f.validate());
foo=null;
assertFalse("contraints failed to block foo=null", f.validate());
Run Code Online (Sandbox Code Playgroud)
然后我会从失败报告中获得有用的信息.这似乎更简洁,并提供更丰富的测试失败报告.
是否有某种方法可以从Spec获得更强大的错误报告,利用所有这些类型的when和then子句,以便它们出现在故障报告中,以便您知道实际上失败了什么?这些"何时"和"然后"文本描述符仅用作内部源文档还是在某处使用?
我一直在关注Burt Beckwith的关于Spring Security for Grails 3的教程.我按照教程中的说法安装了插件build.gradle,并运行了s2-quickstart,这似乎工作正常.该项目无需投诉即可编译.
但是当我尝试import语句时
import grails.plugin.springsecurity.annotation.Secured
Run Code Online (Sandbox Code Playgroud)
导入无法识别,不会构建,但有错误
Error:(2, 1) Groovyc: unable to resolve class grails.plugin.springsecurity.annotation.Secured
Run Code Online (Sandbox Code Playgroud)
少了什么东西?
build.gradle的dependencies部分:
dependencies {
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-dependencies"
compile "org.grails:grails-web-boot"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:hibernate4"
compile "org.hibernate:hibernate-ehcache"
compile 'org.grails.plugins:spring-security-core:3.1.1' //***
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2"
runtime "com.h2database:h2"
testCompile "org.grails:grails-plugin-testing"
testCompile "org.grails.plugins:geb"
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
Run Code Online (Sandbox Code Playgroud) 如果我有一个域Person和一个Domain Hobby,并且Person具有很多Hobby,那么如何确保同一Hobby不会多次添加到Person集合中。
即像
`
class Hobby {
String name
static belongsTo = [person: Person]
}
class Person
String name
static hasMany =[hobby: Hobby]
static constraints= {
hobby.name unique: true //like this
}
}
Run Code Online (Sandbox Code Playgroud) 我需要能够从合同中检索文档,由用户钱包对其进行签名,然后发送回合同并验证签名。
以下是我如何在客户端对 address0 进行签名:
let message : string = "check this message signed by account0";
let messageHash = keccak256(utils.toUtf8Bytes(message));
let signature = await address0.signMessage(messageHash);
await hm.connect(address0).verifyMessage(message, signature);
Run Code Online (Sandbox Code Playgroud)
这是我合同中的验证器:
function verifyMessage(string memory message,
bytes memory signature)
public view returns(bool) {
//hash the plain text message
bytes32 messagehash = keccak256(bytes(message));
//hash the prefix and messagehash together
bytes32 messagehash2 = keccak256(abi.encodePacked("\x19Ethereum Signed Messsage:\n32", messagehash));
//extract the signing contract address
address signeraddress = ECDSA.recover( messagehash2, signature);
if (msg.sender==signeraddress) {
//The message is authentic
return …Run Code Online (Sandbox Code Playgroud) 在ruby和其他一些中,可以为预先存在的祖先类添加一个新方法,并且所有后代都继承它们.我想知道在C#中是否也可以.
例如,我想在Xamarin.Forms中为Page类添加一些方法,这些方法会使它们在所有NavigationPages ContentPages和Page的其他后代上自动可用.你能用C#做那种事吗?
grails ×2
angular ×1
c# ×1
css ×1
ecdsa ×1
ethers.js ×1
grails-2.0 ×1
grails-3.0 ×1
hardhat ×1
javascript ×1
mat-dialog ×1
solidity ×1
spock ×1