我在一个有呼叫的控制器中有一个功能
var someVar = angular.element(event.target).scope().field;
Run Code Online (Sandbox Code Playgroud)
我试图通过这样做来嘲笑它
var ngElementFake = function(el) {
return {
scope: function() {
return {
toggleChildElement: true,
field: scope.field
}
}
}
}
spyOn(angular, 'element').andCallFake(ngElementFake);
Run Code Online (Sandbox Code Playgroud)
但是,当我在测试中调用该函数时,我得到了响应:
TypeError: 'undefined' is not a function (evaluating 'injector.get('$rootElement').off()')
at ../angular-mocks/angular-mocks.js:1819
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
编辑:注射
beforeEach(function() {
inject(function($rootScope, $controller) {
scope = $rootScope;
scope.record = recordData;
scope.model = 'Hierarchy';
ctrl = $controller("fngHierarchyChildCtrl", {
$scope: scope
});
});
});
Run Code Online (Sandbox Code Playgroud) 回发到我的控制器时,我的模型填充了正确的值,我的字符串字段有文件名,但Request.Files为空.
我在视图中的输入是:
<input id="SitePlan" name="SitePlan" type="file" value="<%= Html.Encode(Model.SitePlan) %>" />
Run Code Online (Sandbox Code Playgroud)
我的表单标签以:
<% using (Html.BeginForm(new { enctype = "multipart/form-data" }))
Run Code Online (Sandbox Code Playgroud)
还有什么我需要设置将字段发送回控制器吗?
只有当连接表中的所有关联记录满足某些条件时,如何编写仅返回记录的SQL查询.
例如,如果A有很多B,我想SELECT*FROM A WHERE给定A的所有相关B都有B.some_val>值
我知道这可能是一个非常基本的问题,所以感谢您的帮助.此外,如果它有所作为,我正在使用postgres.
山姆
//inteface i11
public interface i11
{
void m11();
}
//interface i22
public interface i22
{
void m11();
}
//class ab implements interfaces i11 and i22
public class ab : i11, i22
{
public void m11()
{
Console.WriteLine("class");
}
}
Run Code Online (Sandbox Code Playgroud)
现在在Main()方法中我们创建了一个类ab的对象,接口方法将被调用,请解释所有.
我试图过滤掉一些基于正则表达式的文本,如手机*意味着我想要文本"电话亭","手机立方体"等.
但是当我给展位*时,它也选择了电话亭.它不应该选择它吗?这是代码,
string[] names = { "phone booth", "hall way", "parking lot", "front door", "hotel lobby" };
string input = "booth.*, door.*";
string[] patterns = input.Split(new char[] { ',' });
List<string> filtered = new List<string>();
foreach (string pattern in patterns)
{
Regex ex = null;
try
{
ex = new Regex(pattern.Trim());
}
catch { }
if (ex == null) continue;
foreach (string name in names)
{
if (ex.IsMatch(name) && !filtered.Contains(name)) filtered.Add(name);
}
}
foreach (string filteredName in filtered)
{
MessageBox.Show(filteredName); …
Run Code Online (Sandbox Code Playgroud) c# ×2
angularjs ×1
asp.net-mvc ×1
c#-3.0 ×1
file-upload ×1
jasmine ×1
join ×1
oop ×1
postgresql ×1
regex ×1
sql ×1
unit-testing ×1