一旦promise在angularjs中完成,我就会尝试执行检查.
request.then(function(res){
$ionicLoading.hide();
deferred.resolve(res);
}, function(res){
$ionicLoading.hide();
deferred.reject(res);
})['finally'](function(res){
alert(res)
}
)
Run Code Online (Sandbox Code Playgroud)
但警报将以"未定义"的形式出现.
谢谢
ng-init是否关注像ng-model这样的实例化属性的变化?
显然不是,所以我设置了一个如下所示的手表:
app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.$watch('myProp1', function(newVal, oldVal){
$scope.myProp1 = newVal
})
});
Run Code Online (Sandbox Code Playgroud)
HTML
<body ng-controller="MainCtrl">
<input ng-init='myProp="my property"'>{{myProp}}</br>
<input ng-init='myProp1="my 1 property"'>{{myProp1}}</br>
<input ng-init='myProp11="my 11 property"' ng-model='myProp11'>{{myProp11}}
Run Code Online (Sandbox Code Playgroud)
这是plnkr
我正在尝试测试用户模型,为此我设计了身份验证。
我面临的问题是,1. 固定装置中包含“密码”/“密码确认”字段会给我无效的“密码”/“密码确认”列错误。
如果我从固定装置中删除这些列并添加到 user_test.rb
require 'test_helper'
class UserTest < ActiveSupport::TestCase
def setup
@user = User.new(name: "example user",
email: "example@example.com",
password: "Test123",
work_number: '1234567890',
cell_number: '1234567890')
end
test "should be valid" do
assert @user.valid?
end
test "name should be present" do
@user.name = "Example Name "
assert @user.valid?
end
end
Run Code Online (Sandbox Code Playgroud)我收到的错误是:
test_0001_should be valid FAIL (0.74s)
Minitest::Assertion: Failed assertion, no message given.
test/models/user_test.rb:49:in `block in <class:UserTest>'
test_0002_name should be present FAIL (0.01s)
Minitest::Assertion: Failed assertion, no message given.
test/models/user_test.rb:54:in `block …Run Code Online (Sandbox Code Playgroud) 根据定义,equal?检查两个对象是否相同,eql?检查类是否相同且值是否相同.
x = 'hi'
y = 'hi'
x.equal? y # => false
x.eql? y # => true
x = 1
y = 1
x.equal? y # => true
x.eql? y # => true
Run Code Online (Sandbox Code Playgroud)
为什么是第二个x.equal? y true?不是x和y两个实例Fixnum?为什么它不适用于Fixnum/ Float如上面的例子所示?