我在尝试理解为什么双向数据绑定在我的自定义指令中不起作用时遇到了问题?
代码:
指令代码:
.directive('invoiceFilter', function () {
return {
restrict: 'E',
replace: true,
templateUrl: '_invoice-filter.tpl.html',
scope: {
selectedItem: '=',
selectedItemChange: '&'
},
link: function(scope) {
scope.items = {
all: 'Show all invoices',
draft: 'Show drafts only',
open: 'Show open invoices',
paid: 'Show paid invoices'
};
scope.raiseSelectedItemChange = function (key) {
alert('Selected item in directive: ' + key + " (which seems to work!)");
scope.selectedItem = key;
scope.selectedItemChange();
};
}
};
});
Run Code Online (Sandbox Code Playgroud)
指令模板
<div class="btn-group dropdown">
<button class="btn dropdown-toggle" type="button" id="dropdownMenu1" …Run Code Online (Sandbox Code Playgroud) 在我的指令中,我有一个控制器变量,当你按下指令中的按钮时,该页面会增加.但是,scope.alertPage()调用控制器功能的下一行不会反映此更改.请注意,当您单击按钮页面时仍然会被警告为1!
我知道我可以通过在控制器中添加$ scope.$ apply来解决这个问题,但后来我得到的错误是已经发生了摘要.
app = angular.module('app', []);
app.controller('myCtrl', function($scope) {
$scope.page = 1;
$scope.alertPage = function() {
alert($scope.page);
}
})
app.directive('incrementer', function() {
return {
scope: {
page: '=',
alertPage: '&'
},
template: '<button ng-click="incrementPage()">increment page</button>',
link: function(scope, elem, attrs) {
scope.incrementPage = function() {
scope.page += 1;
scope.alertPage();
}
}
}
})
Run Code Online (Sandbox Code Playgroud)
html模板:
<body ng-app='app' ng-controller='myCtrl'>
page is {{page}}
<incrementer page='page' alert-page='alertPage()'></incrementer>
</body>
Run Code Online (Sandbox Code Playgroud) 当鼠标在图表上移动时,我想更改光标,就像这个 fiddle。这适用于 chart.jsv2.4但不适用于v2.6&v2.7
任何想法?
var ctx = document.getElementById("canvas1").getContext("2d");
var mychart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['uno', 'dos', 'tres', 'cuatro'],
datasets: [{
data: [1, 2, 3, 4],
backgroundColor: ["#BDC3C7","#9B59B6","#E74C3C","#26B99A"]
}]
},
options: {
hover: {
onHover: function(e) {
$("#canvas1").css("cursor", e[0] ? "pointer" : "default");
/* without jquery it can be like this:
var el = document.getElementById("canvas1");
el.style.cursor = e[0] ? "pointer" : "default";
*/
}
}
}
});
Run Code Online (Sandbox Code Playgroud) 我有一个关于如何在Laravel中将mysql查询转换为MongoDB的问题
在mysql中我已经离开了连接查询但是在laravel-mongodb中我没有看到相同的左连接查询.
mysql查询
\DB::table('landingpages')->leftjoin('campaigns', 'campaigns.id', '=', 'landingpages.campaign_id')->get();
Run Code Online (Sandbox Code Playgroud)
我改变了我的mongodb
\DB::collection('landingpages')->leftjoin('campaigns', 'campaigns.id', '=', 'landingpages.campaign_id')->get();
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
每次创建新的市场快照时,我都会尝试广播一个事件.我在这里遵循了laravel教程.
但似乎我遗漏了一些东西,因为即使没有创建日志:
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
class NewMarketSnapshot implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the channels the event should broadcast on.
*
* @return Channel|array
*/
public function broadcastOn()
{
\Log::info('event broadcasted');
return new Channel('snapshot');
}
}
Run Code Online (Sandbox Code Playgroud)
我甚至在EventServiceProvider中注册了事件(未在laravel链接上提及)
protected $listen = [
'App\Events\NewMarketSnapshot' => …Run Code Online (Sandbox Code Playgroud) 我正在为我的项目使用数据表。
我想为我的过滤器、分页和搜索选项设置自定义位置。我正在为我的 CSS使用Material MDB Pro。
现在我想将我的长度菜单放置在表格下方,如图所示。
所以我尝试使用此代码:
$('#example').DataTable( {
"dom": '<"top"i>rt<"bottom"flp><"clear">'
} );
Run Code Online (Sandbox Code Playgroud)
但这会让一切都倒闭。连搜索!我想将“搜索”和“导出”按钮保留在顶部,并且只保留分页和长度菜单。
我的代码是:
$(document).ready(function () {
var table = $('#dtMaterialDesignExample').DataTable({
"lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]],
dom: 'Blfrtip',
fixedHeader: true,
buttons: [
{
extend: 'csvHtml5',
title: 'bizRTC CDR <?php date('d-m-Y'); ?>',
customize: function (csv) {
return "Enjoy the file"+csv;
},
className: 'btn btn-outline-primary waves-effect space',
},
{
extend: 'pdfHtml5',
title: 'CDR <?php echo date('d-m-Y'); ?>',
customize: function ( doc ) {
doc.content.splice( 0, …Run Code Online (Sandbox Code Playgroud) jquery datatables datatables-1.10 material-design bootstrap-4
我正在研究 PHP,今天我遇到了字符串 null 的问题。我试图用 GOOGLE 验证太多东西,但没有成功。所以我来这里澄清一下。
我得到了价值 $var1 = "null"
为了验证上面我尝试了以下方法。
$null = is_null($var1);
if($null){
$var1 = null;
}
if($var1 === null){
$var1 = null;
}
if($var1 === "null"){
$var1 = null;
}
Run Code Online (Sandbox Code Playgroud)
但以上方式都不成功。我如何验证$var1 = "null"?
我有代码:
HTML:
<div class="modal-footer" >
<button type="button" class="btn btn-sm btn-default" id="mybutton" style="background-color: #367E2D; color:white; opacity: 1" onclick="chooseme();">OK</button>
</div>
Run Code Online (Sandbox Code Playgroud)
Javascript:
('#mybutton').click(chooseme('123'));
Run Code Online (Sandbox Code Playgroud)
目的:
我想将onClick事件从使用Javascript 更改chooseme()为chooseme('123')
以上代码的结果是:
selectme('123')立即执行(不是点击按钮时)
问题是:任何人都可以解释我的代码有什么问题?什么是达到上述目的的正确实施?
我有数据表,它是表格内的渲染图像,但我所做的只是如果有图像然后渲染但如果没有图像还没有声明
这是我的数据表
<script type="text/javascript">
$(function() {
$('#pengumuman-table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: '{!! route('pengumuman.data') !!}',
columns: [
{ data: 'rownum', name: 'rownum' },
{ data: 'gambar', render: function(data)
{ return '<img src="{{ asset("/images/pengumuman/") }}/'+data+'" atl img style="width:200px; height:150px"/>' }
},
{ data: 'nama_pengumuman', name: 'nama_pengumuman' },
{ data: 'created_at', name: 'created_at' },
{ data: 'action', name: 'action', orderable: false, searchable: false }
]
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
如果在 php 中的数据表中没有图像,我如何添加语句
@if(isset($pegawai->foto) && !empty($pegawai->foto))
<div align="center">
<img src="{{ asset("/images/karyawan/$pegawai->foto") }}" …Run Code Online (Sandbox Code Playgroud) jquery ×3
angularjs ×2
datatables ×2
javascript ×2
laravel ×2
laravel-5 ×2
php ×2
bootstrap-4 ×1
chart.js ×1
cursor ×1
events ×1
html ×1
mongodb ×1
onhover ×1
validation ×1