我正在尝试创建一个自定义过滤器,但当我尝试将其注入我的控制器时,我收到一个"未知提供程序"错误.我已检查并仔细检查了所有参考文献,但我看不出有什么问题.
我知道文件在我的index.html中被正确引用,它被加载并且可以由检查员找到.这是我的代码:
在我的app.js中:
angular.module('equiclass', ['equiclass.controllers',
'equiclass.services',
'ngRoute'])
.config(function ($routeProvider) {
$routeProvider
.when('/courses', {
templateUrl: 'views/courses.html',
controller: 'CourseCtrl'
// And some other stuff with routes
});
angular.module('equiclass.controllers', ['equiclass.services', 'equiclass.filters']);
angular.module('equiclass.services', []);
angular.module('equiclass.filters', []);
Run Code Online (Sandbox Code Playgroud)
我的过滤器:
angular.module('equiclass.filters')
.filter('testFilter', function() {
return function(input) {
return undefined;
};
});
Run Code Online (Sandbox Code Playgroud)
和控制器:
angular.module('equiclass.controllers')
.controller('CourseCtrl', function ($scope, testFilter) {
});
Run Code Online (Sandbox Code Playgroud)
当然这很简单,但它不起作用,我不明白为什么.我已经提供了几项服务,他们都很好地工作和娱乐.
我有一个模态(nbr 1),我从另一个模态打开(nbr 2).模态nbr 1工作正常,并显示它应该的东西.但我试图在模态中输入过滤项目,但输入不起作用.我不能写任何东西,它只是不接受我的意见.
我认为这与我的第二个模态这一事实有关,因为当我从"根"打开它(不是从另一个模态打开它)时,文本输入工作正常.
这是我的HTML:
<div class="modal-header">
<h3 class="modal-title">Pick a student</h3>
<div class="modal-body">
<!-- I can't type in this text field, no matter where it's placed och if it has any attributes at all -->
<input type="text" class="form-control" id="searchUsers" placeholder="Search by name, personal ID number or group" ng-model="search.$" ng-click="console.log('omg')">
<table class="table table-hover table-striped equi-table">
<tbody>
<tr ng-repeat="user in state.users | filter:search:strict">
<td>{{ user.firstName }}</td>
<td>{{ user.lastName }}</td>
<td>{{ user.personalIDNumber }}</td>
</tr>
</tbody>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
这是JavaScript:
这部分从modal nbr 2打开模态:
$scope.addUserToCourse …
Run Code Online (Sandbox Code Playgroud) 所以我想在页面上粘贴一个粘性页脚并让这个为我工作.一切都很好,但不,不是真的......
问题是我希望页脚上方的内容一直延伸到它.现在,包含主要内容的框在框中的文本之后结束,并且页脚和内容之间有一个很大的空间.我想要的是延伸到页脚的主要内容的背景!看到我美丽的形象!
这就是我现在在html中所拥有的:
<div id="wrap">
<!-- start header -->
<div id="header">
<div id="header-content">
</div>
</div>
<!-- end header -->
<!-- start main -->
<div id="main">
<div id="main-content">
</div>
</div>
<!-- end main -->
</div>
<!-- start footer -->
<div id="footer">
</div>
Run Code Online (Sandbox Code Playgroud)
并在CSS中:
html {
height: 100%; }
body {
height: 100%;}
/* wrap */
#wrap {
min-height: 100%; }
/* main */
#main {
background-color: #43145c;
overflow: auto;
padding-bottom: 50px; }
#main-content {
width: 720px;
margin: auto;
background-color: …
Run Code Online (Sandbox Code Playgroud) 我有一个函数foo
,它接受两个数组的并集,它唯一做的就是遍历数组,但是我得到了流式错误,数组中缺少一些属性.是不是可以这样做?我根本没有使用任何属性.它们都是数组,因此流应该知道它们是可迭代的.
type Handle = {|
+articleId: string,
+type: 'handle',
+accessories: Array<string>,
+positionInfo: string,
|};
type Leg = {|
+articleId: string,
+type: 'leg',
|};
type Entity = Handle | Leg;
function foo(entities: Array<Handle> | Array<Leg>) {
entities.forEach(() => {})
}
Run Code Online (Sandbox Code Playgroud) 我正在编写一个LESS嵌套规则,目前看起来像这样:
.content {
margin-bottom: 30px;
&:last-child {
margin-bottom: 0;
}
}
Run Code Online (Sandbox Code Playgroud)
但我想用非选择器来做,而不必两次定义边距.我不想在last-child-selector中重置.
我想做的是这样的:
.content {
&:not(:last-child) {
margin-bottom: 30px;
}
}
Run Code Online (Sandbox Code Playgroud)
结果CSS:
.content:not(:last-child) {
margin-bottom: 30px;
}
Run Code Online (Sandbox Code Playgroud)
但我的语法似乎不对,因为它不起作用,没有元素获得30px的底部边距.
我之前没有使用过not-selector,所以我对语法有点不确定.有可能做,如果是,怎么做?
如何用LESS语法编写一个规则来选择特定div的每个子元素,除了最后一个?