小编Fed*_*les的帖子

AngularJS控制器可以从同一模块中的另一个控制器继承吗?

在模块中,控制器可以从外部控制器继承属性:

var app = angular.module('angularjs-starter', []);

var ParentCtrl = function ($scope, $location) {
};

app.controller('ChildCtrl', function($scope, $injector) {
  $injector.invoke(ParentCtrl, this, {$scope: $scope});
});
Run Code Online (Sandbox Code Playgroud)

示例:死链接:http://blog.omkarpatil.com/2013/02/controller-inheritance-in-angularjs.html

模块内的控制器也可以继承兄弟姐妹吗?

var app = angular.module('angularjs-starter', []);

app.controller('ParentCtrl ', function($scope) {
  //I'm the sibling, but want to act as parent
});

app.controller('ChildCtrl', function($scope, $injector) {
  $injector.invoke(ParentCtrl, this, {$scope: $scope}); //This does not work
});
Run Code Online (Sandbox Code Playgroud)

第二个代码不起作用,因为$injector.invoke需要一个函数作为第一个参数,并且找不到引用ParentCtrl.

inheritance angularjs angularjs-controller

197
推荐指数
6
解决办法
9万
查看次数

AngularJS中的错误处理http get然后构造

当使用AngularJS"http get then"构造(promises)时,如何处理HTTP错误,例如500?

$http.get(url).then(
    function(response) {
        console.log('get',response)
    }
)
Run Code Online (Sandbox Code Playgroud)

问题是,对于任何非200 HTTP响应,都不会调用内部函数.

javascript promise angularjs angular-http angular-promise

65
推荐指数
3
解决办法
10万
查看次数

如何在AngularJS的输入字段中自动调整第一个字符的资本?

如何在AngularJS表单元素内的输入字段中自动调整第一个字符的资本?

我已经看到了jQuery解决方案,但是相信在AngularJS中必须通过使用指令来完成.

input capitalize angularjs angularjs-directive

54
推荐指数
3
解决办法
6万
查看次数

Google Cloud Functions支持CORS?

我刚刚完成了Hello World Google Cloud Functions教程并收到了以下响应标头:

Connection ? keep-alive
Content-Length ? 14
Content-Type ? text/plain; charset=utf-8
Date ? Mon, 29 Feb 2016 07:02:37 GMT
Execution-Id ? XbT-WC9lXKL-0
Server ? nginx
Run Code Online (Sandbox Code Playgroud)

如何添加CORS标头以便能够从我的网站调用我的功能?

cors google-cloud-platform google-cloud-functions

27
推荐指数
4
解决办法
2万
查看次数

如何使用AngularJS模板进行A/B测试?

我正在使用ng-boilerplate,并且必须根据用户配置添加在生产中使用不同模板的可能性.

.config(function config( $stateProvider ) {
 $stateProvider.state( 'demo', {
    url: '/demo',
    views: {
      "main": {
        controller: 'DemoCtrl',
        templateUrl: 'demo/demo.tpl.html'
      }
    }
  });
})
Run Code Online (Sandbox Code Playgroud)

我目前的想法是使templateUrl动态化

templateUrl: 'demo/demo'+userService.getTemplate()+'.tpl.html'
Run Code Online (Sandbox Code Playgroud)

并有多个模板文件,如:

  • demo.tpl.html(默认)
  • demo.b.tpl.html(版本b)
  • demo.c.tpl.html(版本c)

而userService函数确实提供了要使用的模板版本,例如".b"

你同意吗?是否有更好/更容易解决此问题的方法?

ab-testing angularjs

13
推荐指数
1
解决办法
5300
查看次数

如何使用AngularJS指令向选项添加选项?

我有一个选择标记(用于国家选择),我想使用指令预先填充选项:

<select class="countryselect" required ng-model="cust.country"></select>
Run Code Online (Sandbox Code Playgroud)

我的指示如下

return {
  restrict : "C",
  link: function postLink(scope, iElement, iAttrs) {
     var countries = [
        ["AND","AD - Andorra","AD"],
        ["UAE","AE - Vereinigte Arabische Emirate","AE"]
        ... //loop array and generate opt elements
        iElement.context.appendChild(opt);
    }
  }
Run Code Online (Sandbox Code Playgroud)

我可以使用其他选项填充选择,但ng-model绑定不起作用.即使cust.country具有值(例如"UAE"),也不会选择该选项.

如何使select显示cust.country的值?如果认为我在这里有一些时间问题.

javascript angularjs angularjs-directive

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

如何在HTML5应用程序缓存错误事件上获取错误消息?

在我的离线webapp缓存期间,我收到一个完全有效的错误,该错误显示在浏览器控制台中,如下所示:

Application Cache Error event: Manifest changed during update, scheduling retry
Run Code Online (Sandbox Code Playgroud)

我可以添加一个监听器,以通知发生了错误.

window.applicationCache.addEventListener('error', function(e){
  //handle error here
}, false);
Run Code Online (Sandbox Code Playgroud)

如何获取错误详细信息,在这种情况下" 更新期间更改了清单,调度重试 "?

html5 html5-appcache

6
推荐指数
1
解决办法
1837
查看次数

PL / SQL:具有UTF8字符串的UTL_HTTP POST导致字符损坏

我想通过utl_http将UTF8 json字符串通过POST发送到node.js服务器。发送字符串

["Sant Julià de Lòria"]
Run Code Online (Sandbox Code Playgroud)

确实到达

["Sant Juli� de L�ria"]
Run Code Online (Sandbox Code Playgroud)

PL / SQL代码如下所示:

FUNCTION http_post_varchar(
    p_url          VARCHAR2,
    p_request_body VARCHAR2 )
  RETURN VARCHAR2
AS
  req   UTL_HTTP.REQ;
  resp  UTL_HTTP.RESP;
  value VARCHAR2(32767);  -- URL to post to
  v_url VARCHAR2(200) := p_url;
  -- Post Parameters
  v_param VARCHAR2(32767) := p_request_body;
  v_param_length NUMBER := length(v_param);
BEGIN
  req := UTL_HTTP.BEGIN_REQUEST (url=> v_url, method => 'POST');
  UTL_HTTP.SET_HEADER (r      =>  req,
                       name   =>  'Content-Type',
                       value  =>  'application/json;charset=UTF-8');
  UTL_HTTP.SET_HEADER (r      =>   req,
                       name   =>   'Content-Length',
                       value  =>   v_param_length);
  UTL_HTTP.WRITE_TEXT …
Run Code Online (Sandbox Code Playgroud)

oracle post plsql http utf-8

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

使用App Engine Python接收非ascii电子邮件会导致奇怪的字符编码

我正在接收使用Google App Engine Python的电子邮件,并将其存储在数据存储区中.

class LogSenderHandler(InboundMailHandler):
    def receive(self, mail_message):
        logging.info("Received a message from: " + mail_message.sender)
Run Code Online (Sandbox Code Playgroud)

当我收到来自ASCII地址的电子邮件时,一切正常:

我[me@gmail.com]存储为Me [me@gmail.com]

但是,如果发送方值包含非ascii字符,则存储的数据值如下所示:

Kröber先生[mr.kroeber@gmail.com]存储为=?ISO-8859-1?Q?Mr_Kr = F6ber?= [mr.kroeber@gmail.com]

python email google-app-engine encoding ascii

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