小编Mar*_*son的帖子

AngularJS - 模型不更新由ng-repeat生成的单选按钮的选择

我正在使用ng-repeat生成一堆单选按钮,然后在选择其中一个时尝试更新模型.这似乎不起作用.

当无线电输入被硬编码而不是由ng-repeat生成时,相同的标记工作正常.

这有效:

<input type="radio" ng-model="lunch" value="chicken" name="lunch">
<input type="radio" ng-model="lunch" value="beef" name="lunch">
<input type="radio" ng-model="lunch" value="fish" name="lunch">  
{{lunch}}
Run Code Online (Sandbox Code Playgroud)

这不是:

<input type="radio" ng-model="lunch" ng-repeat="m in meat" value="m" name="lunch">    
{{lunch}}
Run Code Online (Sandbox Code Playgroud)

请参阅这里显示的jsfiddle:http://jsfiddle.net/mark_up/A2qCS/1/

任何帮助,将不胜感激.

谢谢

angularjs angularjs-ng-repeat

47
推荐指数
1
解决办法
5万
查看次数

在运行dev_appserver的localhost上使用客户端库保存到GCS时出现404错误

我有一个python GAE应用程序,它使用GCS进行文件存储.它在生产中完美运行,但在dev_appserver上本地运行时完全失败.

任何帮助深究这一点将不胜感激.

谢谢.

码:

BUCKET = '/mybucket'
filename = BUCKET + '/foo.jpg'
gcs_file = gcs.open(filename, 'w', content_type=content_type)
gcs_file.write(file)
gcs_file.close()
Run Code Online (Sandbox Code Playgroud)

错误:

INFO:root:default: "POST /_ah/gcs/mybucket/foo.jpg HTTP/1.1" 404 52
ERROR 2013-11-12 07:45:05,905 webapp2.py:1552] Expect status [201] from Google Storage. But got status 404.
Path: u'/mybucket/foo.jpg'.
Request headers: {'x-goog-resumable': 'start', 'x-goog-api-version': '2', 'content-type': u'image/jpeg', 'accept-encoding': 'gzip, *'}.
Response headers: {'date': 'Tue, 12 Nov 2013 07:45:05 GMT', 'expires': 'Fri, 01 Jan 1990 00:00:00 GMT', 'content-type': 'text/plain; charset=UTF-8', 'content-length': '52', 'server': 'Development/2.0', 'cache-control': 'no-cache'}.
Extra …
Run Code Online (Sandbox Code Playgroud)

google-app-engine google-cloud-storage

7
推荐指数
1
解决办法
2091
查看次数

Magento - 在分组产品表中显示自定义属性

我需要找到一种方法来显示自定义属性的值,而不是下图中显示的"产品名称".

分组产品表http://www.magentocommerce.com/images/uploads/grouped_prod_front.gif

我正在使用/app/design/frontend/default/defaultx/template/catalog/product/view/type/grouped.php

下面的代码不起作用(自定义属性是年份):

<?php if (count($_associatedProducts)): ?>  
<?php foreach ($_associatedProducts as $_item): ?>  
    <tr>  
        <td><?php echo $this->htmlEscape($_item->getYearmade()) ?></td>
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.

编辑:所以答案结果很简单.你看到我上面没有提到的确实有输出......但它只是一个数字(例如:52).原来这是该自定义属性值的ID(它是自定义属性的Dropdown类型).

总结
这适用于文本类型的自定义属性:

echo $this->htmlEscape($_item->getYearmade())
Run Code Online (Sandbox Code Playgroud)

但对于所有其他类型的自定义属性(我认为),应使用以下内容:

echo $this->htmlEscape($_item->getAttributeText('yearmade'))
Run Code Online (Sandbox Code Playgroud)

如果没有Alan Storm提供的最优秀的答案,我就不会发现这一点.谢谢你,先生.

php custom-attributes magento

5
推荐指数
0
解决办法
1万
查看次数

如何加载第三方Joomla扩展的语言文件?

加载位于admin应用程序中的语言文件的常规方法如下:

$language = JFactory::getLanguage();
$language->load('com_yourcomponentname', JPATH_ADMINISTRATOR);
Run Code Online (Sandbox Code Playgroud)

并从站点应用程序加载语言文件:

$language = JFactory::getLanguage();
$language->load('com_yourcomponentname', JPATH_SITE);
Run Code Online (Sandbox Code Playgroud)

这些方法分别从/administrator/language和加载语言文件/language.

目前,我需要从定位其语言文件的模块加载语言文件/modules/mod_foo/language.我该怎么办?

joomla

5
推荐指数
1
解决办法
1745
查看次数

重定向到新页面但记住原始位置

我想在某些条件下将用户发送到“登陆”页面,例如

if (condition) {
        window.location = "http://mywebsite.com/landingpage"
}
Run Code Online (Sandbox Code Playgroud)

但我还想记住用户导航到的原始目的地,以便我可以在登陆页面上放置一个重新重定向链接,将用户移动到原始目的地。

我知道如何使用 PHP 来做到这一点,但我只需要 JS/jQuery 来做到这一点。我可以使用 cookies,如果这能让事情变得更容易的话。

我在想,也许是这样的:

// Condition when user moves to the page
if (condition) {
    // Set cookie with value of current page
    $.cookie('locational_cookie', window.location, { expires: 1}); 
    // Redirect
    window.location = "http://mywebsite.com/landingpage";
}

// When on the landing page, change the href of the "back" link to the original URL that is in the cookie.
$(".landingpage a.back").attr("href", $.cookie('locational_cookie'));
Run Code Online (Sandbox Code Playgroud)

javascript php cookies jquery redirect

3
推荐指数
1
解决办法
2592
查看次数

尝试从GAE python应用程序将文件写入GCS时出现ForbiddenError

我有这个代码:

def save_to_gcs(self, img, img_obj):
    '''
    Image data, Image metadata object -> Blob Key
    Given an image and image metadata, stores it in a GCS bucket
    '''
    bucket = '/foo'
    filename = bucket + '/' + str(img_obj['filename'])

    self.tmp_filenames_to_clean_up = []

    logging.info('Creating file %s\n' % img_obj['filename'])

    write_retry_params = gcs.RetryParams(backoff_factor=1.1)
    gcs_file = gcs.open(filename,
                        'w',
                        content_type=img_obj['mimetype'],
                        retry_params=write_retry_params)
    gcs_file.write(img)
    gcs_file.close()
    self.tmp_filenames_to_clean_up.append(filename)

    return blobstore.create_gs_key('/gs/' + filename)
Run Code Online (Sandbox Code Playgroud)

但它失败了这个错误:

Expect status [201] from Google Storage. But got status 403. Response headers: {'content-length': '145', 'via': 'HTTP/1.1 GWA', 'x-google-cache-control': …
Run Code Online (Sandbox Code Playgroud)

python google-app-engine google-cloud-storage

2
推荐指数
2
解决办法
1603
查看次数

PHP解析错误:语法错误,意外T_STRING

我得到这个语法错误,我知道它是PHP 101,但我不知道php是否用一个大括号击中了我的头部.任何帮助,将不胜感激.谢谢

<?php echo ($this->getProduct()->getCategory() ? $this->getProduct()->getCategory()->getName() : ‘no category’) ?>
Run Code Online (Sandbox Code Playgroud)

php magento

0
推荐指数
1
解决办法
3046
查看次数