主机控制:
function HostingListCtrl($scope, Hosting) {
Hosting.all().success(function(data) {
$scope.hostings = data;
});
}
Run Code Online (Sandbox Code Playgroud)
HTML模板:
<pagination items-count="{{hostings.length}}" current-page="currentPage" items-per-page="{{itemsPerPage}}"></pagination>
Run Code Online (Sandbox Code Playgroud)
指示:
admin.directive('pagination', function() {
return {
restrict: 'E',
replace: true,
templateUrl: "<%= asset_path('angular/templates/ui/pagination.html') %>",
scope: {
currentPage: '=',
itemsCount: '@',
itemsPerPage: '@'
},
controller: function($scope, $element, $attrs) {
console.log($scope);
console.log($scope.itemsCount);
},
link: function(scope, element, attrs, controller) {
}
};
});
Run Code Online (Sandbox Code Playgroud)
我试图在指令中获取 itemsCount 变量的值,但是当我尝试对它进行 console.log 时,该值为空。奇怪的是,当 console.log 整个范围时,它就在那里:
Scope {$id: "005", $$childTail: null, $$childHead: null, $$prevSibling: null,
$$nextSibling: null…}
$$asyncQueue: Array[0]
$$childHead: null
$$childTail: …Run Code Online (Sandbox Code Playgroud) 我的Rails 3应用程序正在使用Grape API.我知道如何在选定的路由上安装该API,mount API => '/api'但我需要在子域上访问该API api.mydomain.com.
我搜索了Grape&Sinatra文档,有关堆栈溢出的问题,并试图谷歌它,但我找不到任何解决方案.
Invalid email or password.当我尝试使用Devise测试登录时,我一直在RSpec功能测试中遇到错误.
规格/功能/ signing_in_spec.rb
require 'spec_helper'
feature 'Signing in' do
let!(:user) { create :user }
scenario 'signs in user with valid credentials', js: true do
visit '/users/sign_in'
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
click_button 'Sign in'
expect(page).to have_content 'Dashboard'
end
end
Run Code Online (Sandbox Code Playgroud)
规格/工厂/ users.rb的
FactoryGirl.define do
factory :user do
email 'user@mail.com'
password '12345678'
password_confirmation '12345678'
factory :admin do
email 'admin@mail.com'
end
end
end
Run Code Online (Sandbox Code Playgroud)
我已经验证用户已保存到数据库中并且正在开发中工作.
我的组件使用dangerouslySetInnerHTML属性呈现HTML 。我需要在酶测试中访问呈现的HTML 。我怎样才能做到这一点?
我已经尝试过了,component.html()但是返回了类似的信息<button ...>[object Object]</button>。
javascript ×2
angularjs ×1
api ×1
capybara ×1
enzyme ×1
reactjs ×1
rspec ×1
ruby ×1
ruby-grape ×1