我在父组件中定义了一个对象,并以单向方式将其传递给第一个子组件和第二个子组件。第一子组件在对象中进行更改。我不明白为什么$onChanges即使对象已更改某些东西,第二个子组件也不会触发。
我在此代码段中有一个项目构建(完整性的链接到JSFiddle)
angular.module('test', [])
.component('parent', {
template: "<first-child bind='vm.obj'></first-child>\
<second-child bind='vm.obj'></second-child>\
",
controller: function(){
this.obj = {value: 0};
this.$onInit = function(){}
},
controllerAs: 'vm',
bindings: {}
})
.component('firstChild', {
template: "<button ng-click='vm.plus()'>+</button>\
<button ng-click='vm.minus()'>-</button>\
",
controller: function(){
this.plus = function(){
this.bind.value++;
}
this.minus = function(){
this.bind.value--;
}
this.$onInit = function(){}
this.$onChanges = function(obj){
console.log('first-child changed one-way bindings', obj)
}
},
controllerAs: 'vm',
bindings: {
bind: '<'
}
})
.component('secondChild', {
template: "<p>{{vm.bind.value}}</p>",
controller: function(){
this.$onInit = …Run Code Online (Sandbox Code Playgroud)我想在<a>标签中搜索,只显示符合要求的标签.因此,当您加载页面时,所有<a>标签都是可见的.当您在搜索框中输入内容时,我想按照其中<a>的标题过滤标记.
$('#search').on('keyup', function(e) {
var search = $(this).val().toLowerCase();
$('#content').children().children().children("p").each(function() {
$(this).parent().parent()[search && $(this).text().toLowerCase().match('^' + search) ? 'show' : 'hide']();
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="search" />
<div class="content">
<a>
<div class="box">
<img>
<p class="title">John</p>
Other content.
</div>
</a>
<a>
<div class="box">
<img>
<p class="title">Jenny</p>
Other content.
</div>
</a>
<a>
<div class="box">
<img>
<p class="title">Jane</p>
Other content.
</div>
</a>
<a>
<div class="box">
<img>
<p class="title">Jack</p>
Other content.
</div>
</a>
</div>Run Code Online (Sandbox Code Playgroud)
上面的JavaScript不起作用.那么如何按标题过滤?
我正在阅读Microsoft 的这篇关于如何将托管类编组到本机以及相反的文章,我遇到了这些内容:
this->!context_node();protected:
!context_node()
{
// method definition
}
Run Code Online (Sandbox Code Playgroud)
我在 Google 和 StackOverflow 上搜索了上述代码片段中感叹号 ( ) 的含义!,但我没有找到任何相关内容,所以我在这里询问是否有人可以解释这一点。
预先感谢任何愿意回答的人。