我需要检查一个表单在控制器中是否有效.
视图:
<form novalidate=""
name="createBusinessForm"
ng-submit="setBusinessInformation()"
class="css-form">
<!-- fields -->
</form>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中:
.controller(
'BusinessCtrl',
function ($scope, $http, $location, Business, BusinessService,
UserService, Photo)
{
if ($scope.createBusinessForm.$valid) {
$scope.informationStatus = true;
}
...
Run Code Online (Sandbox Code Playgroud)
我收到这个错误:
TypeError: Cannot read property '$valid' of undefined
Run Code Online (Sandbox Code Playgroud) 我正在执行一些WPO任务,因此PageSpeed建议我利用浏览器缓存.我已经成功改进了我的Nginx服务器中的一些静态文件,但是仍然缺少存储在Amazon S3服务器中的图像文件.
我已经阅读了有关更新S3中每个文件的方法,以包含一些标头元标记(Expires和Cache-Control).我认为这不是一个好方法.我有成千上万的文件,所以这对我来说不可行.
我认为最方便的方法是配置我的Nginx 1.6.0服务器来代理S3文件.我已经读过这个,但我在服务器配置上并不熟练,所以我从这些网站得到了几个例子:https://gist.github.com/benjaminbarbe/1961db5ffbaad57eff12
我在我的nginx配置文件中的服务器块中添加了这个位置代码:
#inside server block
location /mybucket.s3.amazonaws.com/ {
proxy_http_version 1.1;
proxy_set_header Host mybucket.s3.amazonaws.com;
proxy_set_header Authorization '';
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header Set-Cookie;
proxy_ignore_headers "Set-Cookie";
proxy_buffering off;
proxy_intercept_errors on;
proxy_pass http://mybucket.s3.amazonaws.com;
}
Run Code Online (Sandbox Code Playgroud)
当然,这对我不起作用.我的请求中不包含标头.所以,首先我认为请求与位置不匹配.
Accept-Ranges:bytes
Content-Length:90810
Content-Type:image/jpeg
Date:Fri, 23 Jun 2017 04:53:56 GMT
ETag:"4fd0be549fbcaf9b47c18a15146cdf16"
Last-Modified:Tue, 09 Jun 2015 09:47:13 GMT
Server:AmazonS3
x-amz-id-2:cKsq1qRra74DqVsTewh3P3sgzVUoPR8aAT2NFCuwA+JjCdDZfk7/7x/C0WPjBa51GEb4C8LyAIc=
x-amz-request-id:94EADB4EDD3DE1C1
Run Code Online (Sandbox Code Playgroud) 我的问题很简单.只有一个EC2实例的Amazon Elastic Load Balancer(ELB)是否有意义?
如果我理解正确,ELB将在EC2实例之间切换流量.但是,我只有一个EC2实例.那么,它有意义吗?
另一方面,我使用Route 53将我的域请求domain.com和www.domain.com路由到我的ELB,我不知道如何直接重定向到我的EC2实例.那么,我需要一个ELB用于路由目的吗?
我试图用SSH连接到我的EC2实例,我变得疯狂.我已阅读此帖并尝试了所有用户组合:
AWS ssh访问'Permission denied(publickey)'问题
它仍然不适合我.知道我错过了什么吗?
roberto@ubuntu:~/keys$ ssh -v -i ec2-key-pair.pem ec2-user@ec2-54-72-242-0.eu-west-1.compute.amazonaws.com
OpenSSH_6.6, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-54-72-242-0.eu-west-1.compute.amazonaws.com [54.72.242.0] port 22.
debug1: Connection established.
debug1: identity file ec2-key-pair.pem type -1
debug1: identity file ec2-key-pair.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6p1 Ubuntu-2ubuntu1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat …
Run Code Online (Sandbox Code Playgroud) 我无法将Angular前端与Rails后端API完全集成.它们都运行在不同的服务器上,所以我认为我的CORS存在问题.
我的Angular应用程序正在运行一个控制器,该控制器正在调用具有查询(GET)和保存(POST)方法的资源的服务.查询(GET)工作正常,但帖子不起作用.
当我不发送任何参数时,我能够向服务器发送POST请求.像这样:
控制器:
$scope.createBusiness = function() {
console.log("Business.name=" + $scope.business.name);
$scope.business = Business.save();
};
Run Code Online (Sandbox Code Playgroud)
服务:
.factory('Business',
function($resource){
var businesses =
$resource('http://127.0.0.1\\:3000/:business', {business:'businesses'}, {
query: {method:'GET', isArray: true},
save: {method:'POST', isArray: false}
});
return businesses;
}
Run Code Online (Sandbox Code Playgroud)
);
但是,我想发布我的模型参数,所以当我尝试发送内容时,我不再发送POST请求,而是发送OPTIONS请求.我收到一个错误.
请在发送不带参数的请求时查看我的请求数据(POST请求):
Request URL:http://127.0.0.1:3000/businesses
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:es-ES,es;q=0.8
Connection:keep-alive
Content-Length:0
Content-Type:text/plain;charset=UTF-8
Host:127.0.0.1:3000
Origin:http://localhost:1234
Referer:http://localhost:1234/app/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Response Headersview source
Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, …
Run Code Online (Sandbox Code Playgroud) 我想垂直对齐一个锚元素内的图像,如下所示:
<ul class="thumbnails">
<li class="span2">
<a href="#" class="thumbnail">
<img src="http://www.forodefotos.com/attachments/barcos/17639d1298388532-barcos-vapor-antiguos-barcos-antiguos-vapor-mercantes.jpg" style="max-height: 150px">
</a>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我看了很多帖子,但没有一个对我有用.我也使用Bootstrap缩略图类,我不知道这是否相关,这是它不起作用的原因.
我已经读过我可以设置行高,但有些不对劲.
请看一个简单的plunker.
http://plnkr.co/edit/DsQ80oEiHFn4ma4qfNW8
更新: 我更新了plunker.文本垂直对齐工作正常,但它仍然不适用于图像.
我正在尝试按照本教程:http: //docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.html
为了使用Ubuntu在AWS中部署Ruby on Rails应用程序.
一切顺利(我可以在本地运行我的应用程序),直到最后一步.当我运行aws.push时,我得到下一个错误.
roberto@ubuntu:~/dev/myapp$ git aws.push
Traceback (most recent call last):
File ".git/AWSDevTools/aws.elasticbeanstalk.push", line 21, in <module>
from aws.dev_tools import *
File "/home/roberto/dev/myapp/.git/AWSDevTools/aws/dev_tools.py", line 5, in <module>
import boto
ImportError: No module named boto
Run Code Online (Sandbox Code Playgroud)
我看过这篇文章git aws.push:没有名为boto的模块并运行:
pip install boto
pip freeze > reqIuirements.txt
git add .
git commit -m "Added boto"
git aws.push
Run Code Online (Sandbox Code Playgroud)
但结果仍然相同.
更新:
我认为问题与我的python版本有关.当我运行时,which python
我得到/ usr/bin/python.如果我这个文件夹,我看到python,python2,python2.7,python3,python3.4.
当我跑步时,python
我得到:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on …
Run Code Online (Sandbox Code Playgroud) 我正在使用Angular-translate(PascalPrecht模块).
我成功地按照以下示例使其工作:http://www.ng-newsletter.com/posts/angular-translate.html
但是,我想使用loader-static-files将所有翻译放在不同的json文件中,但这对我不起作用.我不确定我在这里干什么.
在我的角度模块中,我只是使用loader-static调用替换了工作代码(现在已注释):
angular.module('myApp.i18n', ['pascalprecht.translate'])
.config(['$translateProvider', function ($translateProvider) {
/*$translateProvider.translations('en', {
HOME: 'Home',
COMPANIES: 'Companies',
WHAT_TO_DO: 'What to do',
ABOUT: 'About us',
CONTACT: 'Contact'
})
.translations('es', {
HOME: 'Inicio',
COMPANIES: 'Empresas',
WHAT_TO_DO: 'Qué hacer',
ABOUT: 'Nosotros',
CONTACT: 'Contacto'
});*/
$translateProvider.preferredLanguage('es');
$translateProvider.useStaticFilesLoader({
prefix: '/languages/',
suffix: '.json'
});
}]);
Run Code Online (Sandbox Code Playgroud)
我在我的app文件夹中添加了文件:
/app/languages/en_US.json /app/languages/es.json
当我加载我的主站点时,我在控制台中看到下一个错误:
http://localhost:1234/languages/es.json 404 (Not Found)
Run Code Online (Sandbox Code Playgroud)
如果我删除前缀中的第一个'/',如下所示:
$translateProvider.useStaticFilesLoader({
prefix: 'languages/',
suffix: '.json'
});
Run Code Online (Sandbox Code Playgroud)
然后,我在控制台中出现下一个错误:
意外的令牌H.
对不起,我想我不知道这应该如何运作.
我有一个rails应用程序.有时,当用户在文本字段中写入并执行查询以更新MySQL数据库中的此字段时,我会收到此错误日志:
更新船SET描述='Vive laexperienciaúnicadenavegar abordo deunclásicodemadera de lujo como Mako.Teemocionará.',updated_at ='2015-03-10 20:10:32'WHERs boats.id = 1
E, [2015-03-10T20:10:32.223430 #20343] ERROR -- : Mysql2::Error: Incorrect string value: '\xE2\x80\xA8\x09Te...' for column 'description' at row 1: UPDATE boats SET description = 'Vive la experiencia única de navegar abordo de un clásico de madera de lujo como Mako. ? Te emocionará.', updated_at = '2015-03-10 20:10:32' WHERE boats.id = 1
Run Code Online (Sandbox Code Playgroud)
注意:抱歉,我无法将上面的代码作为代码.必须有一个特殊的角色.
我希望用户可以添加任何字符而不会出错.
我有一个开发和生产环境.该错误仅发生在生产中.
我看到这篇文章看起来与我的问题相同:Mysql2 ::错误:字符串值不正确
我运行此查询show variables like 'char%';
来检查数据库字符配置和:开发:
'character_set_client', 'utf8'
'character_set_connection', 'utf8'
'character_set_database', …
Run Code Online (Sandbox Code Playgroud) 我在我的AngularJs应用程序中使用Lazysizes延迟加载旋转木马.
如果我对图像执行lazysizes,它可以工作,但我不喜欢这种效果,因为图像是在用户单击箭头按钮更改图像时加载的,但加载时图像为白色有几毫秒.这是代码:
<div class="carousel slide">
<carousel interval="-10">
<slide ng-repeat="i in imagesList">
<img data-src="image-url.jpg" class="lazyload" />
</slide>
</carousel>
</div>
Run Code Online (Sandbox Code Playgroud)
但是,我想做的是延迟旋转木马本身.但是在加载旋转木马的那一刻,应该装载该旋转木马中的所有图像以避免这种丑陋的效果.
<div class="carousel slide lazyload">
<carousel interval="-10">
<slide ng-repeat="i in imagesList">
<img ng-src="image-url.jpg" />
</slide>
</carousel>
</div>
Run Code Online (Sandbox Code Playgroud)
我不知道该怎么做或者是否有可能.我想我的旋转木马来自bootstrap 2.3.2
angularjs ×4
amazon-ec2 ×2
css ×2
amazon-elb ×1
amazon-s3 ×1
html ×1
http-headers ×1
javascript ×1
jquery ×1
mysql ×1
nginx ×1
proxy ×1
python ×1
ssh ×1
ssh-keys ×1
ubuntu ×1
utf-8 ×1