我知道如何使用EventEmitter引发事件.如果我有这样的组件,我还可以附加一个方法来调用:
<component-with-event (myevent)="mymethod($event)" />
Run Code Online (Sandbox Code Playgroud)
当我有这样的组件时,一切都很好.我将一些逻辑移动到服务中,我需要从服务内部引发一个事件.我做的是这样的:
export class MyService {
myevent: EventEmitter = new EventEmitter();
someMethodThatWillRaiseEvent() {
this.myevent.next({data: 'fun'});
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个组件,需要根据此事件更新一些值,但我似乎无法使其工作.我试过的是这个:
//Annotations...
export class MyComponent {
constructor(myService: MyService) {
//myService is injected properly and i already use methods/shared data on this.
myService.myevent.on(... // 'on' is not a method <-- not working
myService.myevent.subscribe(.. // subscribe is not a method <-- not working
}
}
Run Code Online (Sandbox Code Playgroud)
当引发它的服务不是一个组件时,我如何使MyComponent订阅该事件?
我在On 2.0.0-alpha.28上
编辑:修改我的"工作示例"实际工作,因此可以把重点放在不工作的部分;)
我无法弄清楚如何使用前面的图像CSS
.我已经尝试将z-index设置为1000并定位到相对位置,但它仍然失败.
这是一个例子 -
#header {
background: url(http://placehold.it/420x160) center top no-repeat;
}
#header-inner {
background: url(http://placekitten.com/150/200) right top no-repeat;
}
.logo-class {
height: 128px;
}
.content {
margin-left: auto;
margin-right: auto;
table-layout: fixed;
border-collapse: collapse;
}
.td-main {
text-align: center;
padding: 80px 10px 80px 10px;
border: 1px solid #A02422;
background: #ABABAB;
}
Run Code Online (Sandbox Code Playgroud)
<body>
<div id="header">
<div id="header-inner">
<table class="content">
<col width="400px" />
<tr>
<td>
<table class="content">
<col width="400px" />
<tr>
<td>
<div class="logo-class"></div>
</td>
</tr>
<tr>
<td id="menu"></td>
</tr> …
Run Code Online (Sandbox Code Playgroud)我正在尝试使用电子邮件作为我的表的主键,所以我雄辩的代码是 -
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class UserVerification extends Model
{
protected $table = 'user_verification';
protected $fillable = [
'email',
'verification_token'
];
//$timestamps = false;
protected $primaryKey = 'verification_token';
}
Run Code Online (Sandbox Code Playgroud)
我的DB就像这样 -
但如果我这样做 -
UserVerification::where('verification_token', $token)->first();
Run Code Online (Sandbox Code Playgroud)
我得到这个 -
{
"email": "sdfsdf@sdfsdf.sdf",
"verification_token": 0,
"created_at": "2016-01-03 22:27:44",
"updated_at": "2016-01-03 22:27:44"
}
Run Code Online (Sandbox Code Playgroud)
因此,验证令牌/主键变为0.
有人可以帮忙吗?
我正在尝试实现一个简单的提交输入组.我目前有以下内容:
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="input-group">
<textarea class="form-control custom-control" rows="3" style="resize:none"></textarea> <span class="input-group-btn">
<button class="btn btn-primary">
<span>Send</span>
</button>
</span>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望"发送"按钮占据文本区域的整个高度.这可行吗?
我正在使用Laravel 5并尝试在控制器中获取POST变量的所有输入,如下所示 -
public function add_question()
{
return Request::all();
}
Run Code Online (Sandbox Code Playgroud)
所以,我得到这个错误 -
我做错了什么?
我正在使用AngularJS开发一个应用程序.我想在路由更改时更新元标记.
如何更新AngularJS中可以在页面上的"查看源"中显示的元标记?
这是一个HTML代码 -
<!DOCTYPE html>
<html ng-app="app">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="fragment" content="!" />
<meta name="title" content="Test App">
<meta name="description" content="Test App">
<meta name="keywords" content="Test,App">
<link rel="stylesheet" href="css/jquery-ui-1.10.2.custom.min.css" />
<link rel="stylesheet" href="css/extra.css" />
<script src="js/libs/jquery-1.8.3.min.js"></script>
<script src="js/libs/jquery-ui-1.10.2.custom.min.js"></script>
<script src="js/libs/angular.min.js"></script>
<script src="js/controller.js"></script>
<script src="js/routes.js"></script>
</head>
<body>
<div ng-controller="mainCtrl" class="main-container" loading>
<div class="container-holder">
<div class="container">
<div ng-include src='"elements/header.html"'></div>
<div ng-view class="clearfix"></div>
</div>
</div>
<div ng-controller="userCtrl" id="test">
<div class="container" class="login-container">
<div id="login-logo">
<img src="images/logo-300.png" alt="" class="login-img"/>
<br />
<div ng-view></div> …
Run Code Online (Sandbox Code Playgroud) 我使用的是Google Place API.
我希望得到关于类型帮助的地方的建议.
所以,我所做的是 -
var Google_Places_API_KEY = "AIzaSyAK08OEC-B2kSyWfSdeCzdIkVnT44bcBwM"; //Get it from - https://code.google.com/apis/console/?noredirect#project:647731786600:access
var language = "en"; //'en' for English, 'nl' for Nederland's Language
var Auto_Complete_Link = "https://maps.googleapis.com/maps/api/place/autocomplete/json?key="+Google_Places_API_KEY+"&types=geocode&language="+language+"&input=Khu";
$.getJSON(Auto_Complete_Link , function(result)
{
$.each(result, function(i, field)
{
//$("div").append(field + " ");
//alert(i + "=="+ field);
console.error(i + "=="+ field);
});
});
Run Code Online (Sandbox Code Playgroud)
所以我要求的链接是 -
如果我使用浏览器访问此链接,我可以获得类似的输出(请尝试ck) -
但是,如果我尝试使用jQuery的.getJSON或.ajax,我会通过此消息阻止我的请求 -
.
因此,XMLHTTPRequest被阻止 -
请求的资源上不存在"Access-Control-Allow-Origin"标头.因此不允许原点'null'访问.
我已经在StackOverflow中检查了这个问题的解决方案并通过这里,[这里4和这里,但无法完美地得到我的解决方案.
有谁能请赐教?
我想在laravel 5获得当前的时间戳,我已经完成了 -
$current_time = Carbon\Carbon::now()->toDateTimeString();
Run Code Online (Sandbox Code Playgroud)
我变得很恐怖 - '未找到碳' -
我能做什么?
有人可以帮忙吗?
我想在Bootstrap 3中创建一个自定义选项卡.
我所做的是 -
<ul class="nav nav-tabs" id="myTab">
<script type="text/javascript">
$(document).ready(function() {
//1st (1-1 = 0) tab selected initialy
$("#myTab li:eq(0) a").tab('show');
});
</script>
<li><a data-toggle="tab" href="#sectionA">SEARCH</a></li>
<li><a data-toggle="tab" href="#sectionB">ADVANCED</a></li>
</ul>
<div class="tab-content">
<div id="sectionA" class="tab-pane fade in active">
Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel,
butcher voluptate nisi qui.
</div>
<div id="sectionB" class="tab-pane fade">
Vestibulum nec erat eu nulla rhoncus fringilla ut non neque. Vivamus nibh urna.
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我得到一个这样的标签 -
但我想让它定制有色.我是Bootstrap 3的新手,所以我不知道该怎么做.
我想要的是这样的事情 - …
我想将网页直接保存为PDF.
我所做的是 -
<form>
<input type=button name=print value="Print" onClick="window.print()">
</form>
Run Code Online (Sandbox Code Playgroud)
但它为我提供了打印选项或将页面保存为PDF.
但我想要的是当我点击按钮时,它直接将页面保存为PDF而不显示任何选项.
JavaScript中有任何解决方案吗?
在此先感谢您的帮助.