我是Grunt的新手.我正在尝试在我的Mac OSX Lion上配置Grunt.
我按照这里的说明进行操作,然后创建了一个包含以下文件的项目文件夹.当我尝试通过在终端输入"grunt"来运行时,我得到了command not found.我也修改了我的路径sudo nano /etc/paths,希望添加路径会使任务运行器工作,但它仍然无法正常工作.有人可以协助吗?
---paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/local/bin/grunt
--- files
node modules
Gruntfile.js
package.json
Run Code Online (Sandbox Code Playgroud) 我正在阅读关于Angular验证的这篇文章,并认为在我自己的项目中使用它会很好.它的工作非常好,我希望在成功验证表单后扩展它访问其他控制器中的方法.我尝试了各种方法,但我似乎无法看到$ scope对象中的方法.
<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap-css@3.0.0"
data-semver="3.0.0"
rel="stylesheet"
href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<script data-require="angular.js@1.0.8"
data-semver="1.0.8"
src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="rcSubmit.js"></script>
<script src="loginController.js"></script>
<script src="loginApp.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6 col-sm-offset-3">
<h1>Simple Login Form</h1>
<form name="loginForm" novalidate
ng-app="LoginApp" ng-controller="LoginController"
rc-submit="login()">
<div class="form-group"
ng-class="{'has-error': rc.loginForm.needsAttention(loginForm.username)}">
<input class="form-control" name="username" type="text"
placeholder="Username" required ng-model="session.username" />
<span class="help-block"
ng-show="loginForm.username.$error.required">Required</span>
</div>
<div class="form-group"
ng-class="{'has-error': rc.loginForm.needsAttention(loginForm.password)}">
<input class="form-control" name="password" type="password"
placeholder="Password" required ng-model="session.password" />
<span class="help-block"
ng-show="loginForm.password.$error.required">Required</span>
</div>
<div class="form-group">
<button type="submit" class="btn …Run Code Online (Sandbox Code Playgroud) 我是Angular的新手,想知道在验证失败时如何突出显示表单字段.
我创造了一个小提琴来说明我所追求的东西.
任何帮助表示赞赏.
<p>
<label for="name">User:</label>
<input type="text" name="name" ng-model="name"
required ng-minlength="5" ng-maxlength="32">
<span ng-show="register.name.$error.required" class="err">
Required</span>
<span ng-show="register.name.$error.minlength" class="err">
Minimum 5 characters</span>
<span ng-show="register.name.$error.maxlength" class="err">
Maximum 32 characters</span>
</p>
Run Code Online (Sandbox Code Playgroud) 我刚刚安装了Yeoman并创建了我的第一个项目.我试图让我的头围测试由Yo创建的默认角度项目.当我调用"grunt服务器"时,项目运行正常,但是当我运行单元测试"grunt test:unit"时,我得到错误"Argument'MainCtrl'不是函数,未定义".
为了让这个测试正常运行,我缺少什么?
再次感谢
- 控制器
'use strict';
angular.module('myApp')
.controller('MainCtrl', function ($scope) {
$scope.awesomeThings = [
'HTML5 Boilerplate',
'AngularJS',
'Karma',
'mytest'
];
});
Run Code Online (Sandbox Code Playgroud)
- unti测试
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('myApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(4);
});
});
Run Code Online (Sandbox Code Playgroud) 我正在使用实体框架4.0,我的查询语法有些问题.我正在尝试连接2个表并传递一个参数来同时查找该值.我想通过查找表1中的相关值来查找表2中的所有产品.
有人可以帮我解决语法问题吗?
提前致谢.
样本数据
表格1
ID productID categoryID
361 571 16
362 572 17
363 573 16
364 574 19
365 575 26
Run Code Online (Sandbox Code Playgroud)
表2
productID productCode
571 sku
572 sku
573 sku
574 sku
575 sku
var q = from i in context.table1
from it in context.table2
join <not sure>
where i.categoryID == it.categoryID and < parameter >
select e).Skip(value).Take(value));
foreach (var g in q)
{
Response.Write(g.productID);
}
Run Code Online (Sandbox Code Playgroud) 我有一个问题,我的点击事件被调用两次.不知道我错过了什么,但我只在我的应用程序中包含了这个指令.我试过只将指令添加到一个元素,但调用仍然发生两次.
有人可以看看代码并告诉我我错过了什么吗?
angular.module('mymodule', [])
.directive('mydirective', function () {
return {
restrict: 'AE',
link: function ($scope, $element, $attrs) {
$element.children().bind('click', function () {
console.log("test" + this);
if ($element.hasClass('active')) {
$element.removeClass('active');
return;
} else if (!$element.hasClass('active')) {
$element.addClass('active');
return;
}
});
}
}
});
Run Code Online (Sandbox Code Playgroud)