这是显示问题的小提琴.http://jsfiddle.net/Erk4V/1/
如果我在ng-if中有ng模型,则该模型似乎不能按预期工作.
我想知道这是一个错误还是我误解了正确的用法.
<div ng-app >
<div ng-controller="main">
Test A: {{testa}}<br />
Test B: {{testb}}<br />
Test C: {{testc}}<br />
<div>
testa (without ng-if): <input type="checkbox" ng-model="testa" />
</div>
<div ng-if="!testa">
testb (with ng-if): <input type="checkbox" ng-model="testb" />
</div>
<div ng-if="!someothervar">
testc (with ng-if): <input type="checkbox" ng-model="testc" />
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我是url重写的新手.到目前为止,我的htaccess文件大约有20个重写文件.我很好奇,如果我有更多,它会减慢我的页面加载或任何类型的东西?
我正在尽我所能来构建我的网址,这样我就可以进行最小的重写,但我不确定我是否已经因为已经有20个已经失败了.
RewriteRule ^account/(\w+)(.*)$ ./index.php?option=account&task=$1 [L,PT]
# Auth Controller
RewriteRule ^auth/(\w+)(.*)$ ./index.php?option=auth&task=$1 [L,PT]
# Collections Controller
RewriteRule ^collections(.*)$ ./index.php?option=collections [L,PT]
RewriteRule ^collections/(\w+)(.*)$ ./index.php?option=collections&task=$1 [L,PT]
# Friends Controller
RewriteRule ^friends/(\w+)(.*)$ ./index.php?option=friends&task=$1&%{QUERY_STRING} [L,PT]
# Index Controller
RewriteRule ^index(.?)$ ./index.php?%{QUERY_STRING} [L,PT]
RewriteRule ^index/index(.?)$ ./index.php?%{QUERY_STRING} [L,PT]
RewriteRule ^about(.*)$ ./index.php?option=index&task=about [L,PT]
RewriteRule ^ideas(.*)$ ./index.php?option=index&task=ideas [L,PT]
RewriteRule ^contact(.*)$ ./index.php?option=index&task=contact [L,PT]
RewriteRule ^faq(.*)$ ./index.php?option=index&task=faq [L,PT]
# Messages Controller
#RewriteRule ^messages/(\d+)(.*)$ ./index.php?option=messages&account_id=$1 [L,PT]
# Run Controller
RewriteRule ^run/(\d+)(.*)$ ./index.php?option=run&account_id=$1 [L,PT]
# Stores Controller
RewriteRule ^stores/(\w+)(.?)$ ./index.php?option=stores&task=$1 [L,PT]
Run Code Online (Sandbox Code Playgroud) 在延迟对象的回调之前,我无法在每个ajax请求上执行done/fail/always回调.
我遇到的问题是我的一些ajax请求可能会失败,但我需要执行相同的代码,无论是失败还是没有失败.
很难准确解释,所以我做了这个小提琴,以帮助显示我遇到的问题. http://jsfiddle.net/zZsxV/
var a1 = $.Deferred();
var a2 = $.Deferred();
var a3 = $.Deferred();
a1.done(function() {
$('body').append('a1 done<br />');
}).fail(function() {
$('body').append('a1 fail<br />');
}).always(function() {
$('body').append('a1 always<br />');
});
a2.done(function() {
$('body').append('a2 done<br />');
}).fail(function() {
$('body').append('a2 fail<br />');
}).always(function() {
$('body').append('a2 always<br />');
});
a3.done(function() {
$('body').append('a3 done<br />');
}).fail(function() {
$('body').append('a3 fail<br />');
}).always(function() {
$('body').append('a3 always<br />');
});
var def = $.when(a1, a2, a3);
def.always(function() {
$('body').append('defer always <-- should be after all<br />'); …Run Code Online (Sandbox Code Playgroud) 我有一个在javascript中运行的for循环.在这个循环中,我创建了一个列表项并将click事件绑定到它.当我单击此列表项时,我希望它使用当前循环对象中的数据作为参数调用函数.
问题是,无论我点击什么列表项.作为参数传递的数据是我循环的对象的最后一个元素,而不是当前被单击的对象.
for(e in data) {
var suggestItem = $('<li>'+ data[e]['name'] +'</li>');
suggestItem.click(function() {
$(this).addClass('activeSuggestion');
suggestSelect(suggestField, data[e]);
});
suggestList.append(suggestItem);
}
Run Code Online (Sandbox Code Playgroud)
我想我明白为什么会这样,但不知道我应该如何处理它.
我想知道为每个用户创建一个文件夹是不是一个坏主意.因此,可以使用img.mysite.com/UserId/image.jpg访问每个用户的任何图像
不知道怎么说这个.
我试图使用变量来确定钻入对象返回值的距离.
var target = "level1.level2.var";
var myObject = {
level1: {
level2: {
var: 'value'
}
}
}
var returnVal = myObject.target;
Run Code Online (Sandbox Code Playgroud)
怎么可以这样做?显然这不起作用.有可能是其他方式吗?
我想我可能必须爆炸目标var然后循环每个级别,但我想我会问是否有更容易的方式我可以忽略.
我不确定如何提出这个问题.基本上我试图让我的视图对象从Smarty对象扩展出来.然后,我希望能够将视图对象扩展到我的控制器对象.
View对象将为我的所有控制器分配我想要的模板变量.
我知道我现在有什么问题,但如果有人能指出我正确的方向,那将是非常棒的.我尽力说出最好的话.
<?php
defined('SITE_ROOT') ? null : define('SITE_ROOT', $_SERVER['DOCUMENT_ROOT'].'/mvcsandbox');
require_once('Smarty/Smarty.class.php');
class View extends Smarty {
public static $instance=NULL;
public static function getInstance(){
if ( self::$instance === null ){
self::$instance = new self();
}
return self::$instance;
}
public function __construct() {
$this->template_dir = SITE_ROOT.'/Library/tmp/';
$this->compile_dir = SITE_ROOT.'/Library/tmp/';
$this->config_dir = SITE_ROOT.'/Library/tmp/';
$this->cache_dir = SITE_ROOT.'/Library/tmp/';
$this->assign("var1", "This is from the view class");
}
public static function output() {
self::display('test.tpl');
}
}
class Controller1 extends View {
public function init() {
$this->assign("var2", "This …Run Code Online (Sandbox Code Playgroud) var_dump()新的 Xdebug 似乎在调试模式下禁用了重载功能。我喜欢同时使用断点调试,但我被迫在var_dump 和断点之间var_dump()来回交换。xdebug.mode=developxdebug.mode=debug
有什么办法可以让超载的人var_dump()在入住时可以使用吗xdebug.mode=debug?
这不是世界末日,但当我需要清理var_dump()以进行快速分析时,必须来回交换有点烦人。