我是yii2的新手.我一直试图使用post方法从视图中向一个动作发送一些参数,不幸的是我的动作似乎没有看到/接收它们.帮助将非常感激.
我的列操作是这样的:
'buttons'=> [
'password'=> function ($url, $model, $key){
$url =$url = Url::toRoute(['users/reset-password', 'username' => $model->username]);
return Html::a('<span class="glyphicon glyphicon-asterisk"></span>',$url,[
'title'=>'Clave',
'data-confirm' => Yii::t('yii', 'Are you sure you want to change this password?'),
'data-method' => 'post',
'data' => ['username'=>$model->username, 'test-name'=>'this is just for testing'],
]);
},
.....
Run Code Online (Sandbox Code Playgroud)
data参数中的所有内容都应该通过post发送,但我只获取csrf令牌..请提前感谢您的帮助.
我需要提供一个下载文件的链接,链接必须被任何用户隐藏和访问,这是我的代码,没有任何错误,但我甚至无法打开下载对话框:
模板
<a ng-href="#" target="page" type="button" class="btn"
ng-click="download()">Download</a>
Run Code Online (Sandbox Code Playgroud)
脚本文件
$scope.download = function(){
//here i need to know the code,can anybody explain me
}
Run Code Online (Sandbox Code Playgroud) 我试图使用关系作为创建标准的一部分CActiveDataProvider.我有以下内容:
用户模型:
return array(
'favourites'=>array(self::HAS_MANY, 'UserFavourite', 'user_id', 'order'=>'added_at DESC'),
);
Run Code Online (Sandbox Code Playgroud)
UserFavourite模型:
return array(
'user'=>array(self::BELONGS_TO, 'User', 'user_id'),
'listing'=>array(self::BELONGS_TO, 'Listing', 'listing_id'),
);
Run Code Online (Sandbox Code Playgroud)
控制器(查看收藏夹操作):
$user = $this->loadUser(Yii::app()->user->id);
Run Code Online (Sandbox Code Playgroud)
如何CActiveDataProvider在我的用户模型中创建一个favourites由当前用户提取所有内容的模型- 以及listing每个收藏夹的相关模型数据?所以我想做点什么$favourites = $user->getFavourites();.
本CActiveDataProvider应返回数组Listing对象.它应该支持分页和排序 - 默认排序added_at DESC.
我试过使用with选项,CDbCriteria但似乎不起作用......
我想在我的邮件正文中嵌入图像,并按照http://www.yiiframework.com/doc-2.0/guide-tutorial-mailing.html上的文档进行操作.
我在控制器中的代码如下所示:
$messages[] = Yii::$app->mailer->compose('downNotify', [
'websiteList' => $websiteList,
'logo' => Url::to('@web/mail/images/logo.png')
])
Run Code Online (Sandbox Code Playgroud)
并在邮件视图文件中:
<a href="#"><img width="100" src="<?= $message->embed($logo); ?>"></a>
Run Code Online (Sandbox Code Playgroud)
但是,当我运行它时,它给了我错误:
fopen(/WEBSITE_MONITOR/web/mail/images/logo.png):无法打开流:没有这样的文件或目录
路径有效,但我不知道为什么会出现此错误.有没有人有类似的问题?
我有Angular材质导航栏(如下所示).我在导航栏中放了一个md菜单,因为我想实现右侧有下拉菜单的bootstrap导航栏.如何移动"WELCOME!IVAN",这是右侧的下拉菜单.
下面是我的代码:
<div ng-controller="navController">
<md-content>
<md-nav-bar md-selected-nav-item="currentNavItem" nav-bar-aria-label="navigation links">
<md-nav-item md-nav-href="#{{ link.url}}" ng-repeat="link in navUrl" name="{{ link.url.substr(1)}}">
<i class="fa {{ link.icon}}" aria-hidden="true"></i>
{{ link.link}}
</md-nav-item>
<md-menu md-offset="0 -7" layout-align="end center">
<md-button aria-label="Open menu" class="md-button" ng-click="$mdMenu.open($event)">
Welcome! {{ user}}
<!--<md-icon md-menu-origin md-svg-icon="call:phone"></md-icon>-->
<i class="fa fa-user" aria-hidden="true"></i>
</md-button>
<md-menu-content width="3">
<md-menu-item>
<md-button ng-click=""> <span md-menu-align-target>Logout</span></md-button>
</md-menu-item>
</md-menu-content>
</md-menu>
</md-nav-bar>
</md-content>
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助!!!:)
我正在尝试对组件内部的功能进行单元测试,此功能是根据初始条件从ngOnInit调用的:
ngOnInit() {
if (this.list.length === 0) {
return this.loadData();
}
return this.isLoading = false;
}
// I'm calling here because it could also be called from button on the UI
loadData() {
this.apiService.apiGet().subscribe((response) => {
// handle data
return this.isLoading = false;
}, (error) => {
// handle error
return this.isLoading = false;
})
}
Run Code Online (Sandbox Code Playgroud)
但是,除非我在测试中手动调用该函数,否则我无法对其进行测试。这是我的测试代码:
// THIS CODE WORKS
it('should be false after calling loadData()', async(() => {
component.loadData();
fixture.detectChanges();
fixture.whenStable().then(() => {
expect(component.isLoading).toBeFalsy();
});
}));
// THIS …Run Code Online (Sandbox Code Playgroud) 我实施了一项支票,不想上传尺寸大于的图片4MB。我正在使用file reader和new image()。我有图像的大小和宽度。但是,如何获取文件大小。
function previewImage(element) {
var reader = new FileReader();
reader.onload = function (event) {
seAddArtist.imageSource = event.target.result;
$scope.$apply();
};
// when the file is read it triggers the onload event above.
reader.readAsDataURL(element.files[0]);
}
var img = new Image();
img.onload = function () {
alert(this.width + 'x' + this.height);
}
Run Code Online (Sandbox Code Playgroud)
我正在实现这两个结合,但如何检查图像的大小?
我已经写了特定的YII2表格标签
<?php $form = ActiveForm::begin(['id' => 'builder/saveform','options' => ['method' => 'post']]) ?>
Run Code Online (Sandbox Code Playgroud)
但是当我运行这个时,我的外部JavaScript会出现错误
Error: Syntax error, unrecognized expression: #builder/saveform
Run Code Online (Sandbox Code Playgroud)
什么是错误
我真的不明白为什么这个标记不能识别我的 $stateProvider?
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due
to: Error: [$injector:unpr] Unknown provider: $stateProvider
Run Code Online (Sandbox Code Playgroud)
简单模块:
(function () {
'use strict';
// get modules we need for the app
angular.module('app', ['ngRoute'])
.config(config);
config.$inject = ['$stateProvider']
function config($stateProvider) {
console.log('works'); // actually doesn't
};
})();
Run Code Online (Sandbox Code Playgroud)
我尝试了各种其他样式,例如直接在配置中加载它们
.config(['$stateProvider'], function ($stateProvider) {
// not working this way either.
});
Run Code Online (Sandbox Code Playgroud) 我有以下 Bower.json 文件:
{
"private": true,
"dependencies": {
"angular": "~1.5.0",
"angular-mocks": "^1.5.7",
"bootstrap": "^3.3.6",
"bootstrap-rtl": "^3.4.0",
"font-awesome": "^4.6.3",
"moment": "^2.13.0",
"angular-animate": "^1.5.6",
"angular-sanitize": "^1.5.6",
"angular-ui-router": "~0.2.15",
"angular-translate": "^2.11.0",
"angular-touch": "^1.5.7",
"angular-messages": "^1.5.6",
"angular-cookies": "^1.5.8",
"angular-ui-grid": "^3.1.1",
"angular-ui-sortable": "^0.14.2",
"angular-bootstrap-affix": "^0.2.2",
"theia-sticky-sidebar": "^1.4.0",
"angular-ui-router-title": "^0.0.4",
"angularjs-slider": "^4.0.2",
"angular-fcsa-number": "^1.5.3",
"angularPrint": "angular-print#^0.3.8",
"ng-virtual-keyboard": "^0.3.0",
"keyboard": "^1.26.1",
"angular-spinner": "^0.8.1",
"ng-ip-address": "^1.1.10",
"file-saver": "^1.3.2",
"ng-iban": "^1.1.0",
"pdfmake": "^0.1.20",
"ng-device-detector": "^3.0.1",
"checklist-model": "^0.10.0",
"angular-dynamic-number": "^2.1.1",
"ng-file-upload": "^12.2.13",
"ng-file-upload-shim": "^12.2.13",
"angular-ui-select": "^0.19.6",
"angular-dragula": "^1.2.8",
"angular-drag-and-drop-lists": "^2.0.0", …Run Code Online (Sandbox Code Playgroud) angularjs ×5
javascript ×4
php ×4
yii2 ×3
html ×2
activerecord ×1
angular ×1
bower ×1
css ×1
filereader ×1
gridview ×1
mailer ×1
parameters ×1
post ×1
unit-testing ×1
yii ×1