小编dan*_*eta的帖子

Material Design Lite与AngularJS集成

我知道Angular Material有助于实现Material Design规范,以便在Angular单页面应用程序中使用.

然而,我正在考虑使用Material Design Lite替代我的Angular项目.我想知道将Material Design Lite与AngularJS应用程序集成的最佳方法.

javascript angularjs material-design-lite

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

Angularjs打破了coffeescript函数表达式

我正在努力将AngularJs集成到一个示例Nodejs应用程序中.我的控制器如下:

UsersCtrl = ($scope, $http) ->    
   $scope.newUser = {}
   $scope.users = [
     name: "aloman"
     email: "aloman@example.com"
   ]
Run Code Online (Sandbox Code Playgroud)

编译成javascript:

// Generated by CoffeeScript 1.3.3
(function() {
  var UsersCtrl;

  UsersCtrl = function($scope, $http) {
    $scope.newUser = {}; 
    return $scope.users = [ 
      {   
        name: "aloman",
        email: "aloman@example.com"
      }   
    ];  
  };
}).call(this);
Run Code Online (Sandbox Code Playgroud)

上面的代码打破了控制台日志:
错误:参数'UsersCtrl'不是函数,未定义

但是删除包含在已编译的javascript中的匿名函数可以正常工作.工作代码如下所示.

var UsersCtrl;
Usersctrl = function($scope, $http) {
    $scope.newUser = {};
    $scope.users = [{
        name: "aloman",
        email: "aloman@example.com" 
    }];
}; 
Run Code Online (Sandbox Code Playgroud)

我的编译代码无法正常工作的原因.我有一种感觉它与Angular的示波器注入有关.我正在使用AngularJS 1.0.1

javascript coffeescript angularjs

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

Rails3 Active Admin - 如何仅过滤符合集合中所有已检查项目的记录

我有一对多的用户与网络模型的关联.我的架构信息的相关部分如下.

# == Schema Information      
# Table name: users
#
#  id                     :integer         not null, primary key
#  name                   :string(255)

#
# Table name: networks
#
#  id         :integer         not null, primary key
#  user_id    :integer
#  uid        :string(255)
#  name   :string(255)
#  pub_url    :string(255)
Run Code Online (Sandbox Code Playgroud)

我想使用网络模型的name属性过滤掉具有特定多个网络的用户.例如,如果我将facebook和foursquare作为过滤器检查,我想找回连接facebook和foursquare的用户.我目前的实现是传递一个数组,其中包含用户可以添加的网络名称,如下所示.

filter :networks_name, :as => :check_boxes,
:collection => %w(facebook twitter foursquare linkedin)
Run Code Online (Sandbox Code Playgroud)

但是,这对过滤器使用OR条件,该过滤器检索具有任何已检查项的用户.我真正想要的是满足所有检查项目的用户.实现这一目标的正确方法是什么?

ruby-on-rails activeadmin

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

如何使用Testacular + AngularJS测试外部服务的应用程序

我有一个运行的应用程序http://localhost:6543- 这是一个金字塔应用程序.

  • 这个应用程序服务于AngularJS应用程序/
  • 这个应用程序使用socket.io本身

问题是: 是否可以使用这些工具测试该应用程序?

我在我的scenario.js文件中有这个:

beforeEach(function() {
   browser().navigateTo('http://localhost:6543/');
});
Run Code Online (Sandbox Code Playgroud)

但是当我启动testacular(带runstart)时,我收到此错误消息:

Chrome 23.0 registration: should delete all cookies when user clicks on "remove all" button FAILED
browser navigate to 'http://localhost:6543/'
/home/abourget/myapp/jstests/scenarios/registration_scenario.js:9:5: Sandbox Error: Application document not accessible.
Run Code Online (Sandbox Code Playgroud)

所以我理解浏览器不允许访问该iframe文档,因为它是一些跨源违规.

我尝试了什么:

  • 使用Testacular网络服务器(带proxies选项)访问我的应用程序,但/会与Testacular自己的框架服务冲突.此外,这两个应用程序最终都会尝试使用/socket.io,这也会发生冲突.
  • 反过来(调整我的应用程序代理到Testacular的服务器),但是,我们会遇到同样的问题/socket.io.

感谢这些伟大的工具,顺便说一句!

javascript jasmine angularjs karma-runner

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