我想使用illuminate\html创建一个类似下面的选择框:
<select>
<option value="$item->id">$item->name</option>
<option value="$item->id">$item->name</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我尝试了这个:
public function create()
{
$items = Items::all(['id', 'name']);
return view('prices.create', compact('id', 'items'));
}
Run Code Online (Sandbox Code Playgroud)
在我看来这个:
<div class="form-group">
{!! Form::Label('item', 'Item:') !!}
{!! Form::select('item_id', $items, null, ['class' => 'form-control']) !!}
</div>
Run Code Online (Sandbox Code Playgroud)
问题是,而不是$item->name显示实体的所有信息.
我有这个:
<div class="account-item">
<div class="account-heading" ng-class="active">
<h4 class="account-title">
<a href="#/Messages" onclick="SetActiveAccountHeading(this);">
7. @Translate("SYSTEM_MESSAGES")</a>
</h4>
</div>
</div>
<div class="account-item">
<div class="account-heading" ng-class="active">
<h4 class="account-title">
<a href="#/Info" onclick="SetActiveAccountHeading(this);">
7. @Translate("SYSTEM_INFO")</a>
</h4>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
在角度我有这个:
$scope.active = "active";
Run Code Online (Sandbox Code Playgroud)
但是如何在点击时更改此项,如果用户点击菜单一旦它将处于活动状态,如果再次单击它将不活动?
我使用 sqlite 在 php 中开发一个 web 应用程序,将数据存储在数据库中。正如在互联网上看到的,我使用 PDO 而不是 SQLITE3 类。我执行了互联网上显示的所有步骤来避免此错误消息,但它仍然出现:
SQLSTATE[HY000] [14] 无法打开数据库文件
周期性任务每 30 秒运行一次,以获取表中的条目数。该任务由 Javascript/Jquery 触发。在普通的 php 文件上,使用 PDO 没有任何问题。但是将它与 Javascript/Jquery 结合使用时我收到了上面的消息。
我已经将整个路径和数据库设置为网络服务器的用户/组并设置为 chmod 0777。
我自己编写的数据库类被创建并存储在会话变量中,以避免在网页生命周期中创建和销毁。
该函数连接到数据库(该函数和下一个函数位于同一类中):
private $db = null;
private function connectdb(){
try {
$this->db = new PDO(database,"","",array(
PDO::ATTR_PERSISTENT => TRUE,
PDO::ERRMODE_EXCEPTION => TRUE));
} catch (PDOException $e) {
logerror($e->getMessage(), "connecthrsedb");
return exception;
}
}
Run Code Online (Sandbox Code Playgroud)
该函数正在执行查询:
function getNumberofEntriesinTable() {
try {
if (is_null($this->db)) {
if ($this->connectdb() < 0) {
return -1;
}
}
$statement = …Run Code Online (Sandbox Code Playgroud) 我正在使用谷歌字体的Amatic SC 700普通版.
这是谷歌字体上的链接:https://www.google.com/fonts/specimen/Amatic+SC.
问题是现在char ?被转换成了®.
我使用的CSS代码是:
@import url(http://fonts.googleapis.com/css?family=Amatic+SC:400,700);
body {
font-family: 'Amatic SC', cursive;
font-style: normal;
font-weight: 700;
}
Run Code Online (Sandbox Code Playgroud)
html看起来像这样:
<html> ???? </html>
Run Code Online (Sandbox Code Playgroud)
这是该问题的屏幕截图:
这是jsfiddle链接:http://jsfiddle.net/m4vev43a/
我测试了这个问题:
知道如何解决这个问题吗?
我的浏览器变得疯狂吗?
或者这是字体中的错误?
更新:
使用时:
@import url(http://fonts.googleapis.com/css?family=Amatic+SC);
Run Code Online (Sandbox Code Playgroud)
因此,如果没有后缀:400,700,则会正确显示问号字符.
不幸的是,使用上面的代码+粗体文本完全搞乱了Chrome,Firefox,Opera中的字母间距.
在laravel中,如果我想将参数传递给路由文件中的控制器
Route::get('user/sk/{id}' , 'UsersController@findsk');
Run Code Online (Sandbox Code Playgroud)
如果我想传递默认参数:
Route::get('user/{name?}', function ($name = 'John') {
// how do I invoke my controller here?
return $name;
});
Run Code Online (Sandbox Code Playgroud)
我如何合并这两件事?有捷径吗?
Route::get('user/sk/{id}' , 'UsersController@findsk'
// can I add an array of default parameters here?
);
Run Code Online (Sandbox Code Playgroud) 我正在创建一组REST API,以使用laravel存储库模式向我的移动应用程序公开。我正在使用dingo作为REST框架。我对应该如何使用转换器完成API的响应感到困惑。
我具有以下控制器功能
if(!$user) {
//Authenticate with Twitter and authenticate
//Register user and issue jwt
$user = Sentinel::register($device_details);
$user_data = json_decode($user,true);
$device_details['users_id'] = $user['users_id'] = $user_data['id'];
$this->device_details->create($device_details);
}
$token = JWTAuth::fromUser($user);
$user_array = $user->toArray();
$user_array['token'] = $token; //An array containing user details and token
return $this->response->item($user_array, new UserTransformer)->setStatusCode(200); //I can only pass an object (eloquent) as the #1 parameter
Run Code Online (Sandbox Code Playgroud)
我的变形金刚课
namespace App\Api\V1\Transformers;
use App\User;
use League\Fractal\TransformerAbstract;
class UserTransformer extends TransformerAbstract {
public function transform(User $user)
{
return [
'users_id' => …Run Code Online (Sandbox Code Playgroud) 我试图取消选择角度2中的单选按钮。我尝试了以下代码,但无济于事。
.html
<div [formGroup]="myForm">
<mat-radio-group matInput (click)= "resetRadio($event)" formControlName="RdoSel">
<mat-radio-button *ngFor="let RadioOpt of RadioOpts" [value]="RadioOpt .id">{{RadioOpt .value}}</mat-radio-button>
</mat-radio-group>
</div>
Run Code Online (Sandbox Code Playgroud)
.ts
public RadioOpts= [
{ id: 'Market', value : 'Market'},
{ id: 'Segment', value : 'Segment'}
];
public resetRadio(event: any) {
if(myForm.get('RdoSel').value===event.target.value){
myForm.get('RdoSel').setValue('false');
}
Run Code Online (Sandbox Code Playgroud)
当我console.log(event.target.value)返回div标签。有人可以告诉我如何取消选择角度2中的单选按钮吗?
我收到此错误
错误:(17, 35) TS2339:类型“EventTarget & Element”上不存在“checked”属性。
但这绝对是不可能的错误,因为 React 文档说checked确实存在target复选框(https://reactjs.org/docs/forms.html#handling-multiple-inputs)
这是我的代码。有什么问题让 TS 炸了?
// I specify a type for event. It must have `checked` property.
onToggle = (ev: React.ChangeEvent) => {
console.log('[ev]', ev.target.checked); // <= TS throws here
}
render() {
return (
<div>
<input type="checkbox" name="switch" id="switch" onChange={ev => this.onToggle(ev)} checked={this.state.on}/>
</div>
)
}
Run Code Online (Sandbox Code Playgroud)
替代错误消息:
TS2339:“EventTarget”类型上不存在“checked”属性。
我按照说明在https://facebook.github.io/jest/docs/getting-started.html#content上安装了 Facebook jest :
npm install --save-dev jest-cli
Run Code Online (Sandbox Code Playgroud)
在我jest在终端中输入安装命令后,按回车键但它弹出:
bash: jest: command not found.
Run Code Online (Sandbox Code Playgroud)
但是当我npm test在终端中使用 using 运行入门示例时,它运行良好。
那么,如何验证 Facebook jest 是否已成功安装?