我已经使用ckeditor插件在angularjs中创建了一个应用程序,我已经为ckeditor创建了一个指令,该应用程序工作正常,但问题是我需要将最大字符长度设置为50,所以我放了maxlength="50",但它不起作用,
任何人都可以告诉我一些解决方案
HTML
<div data-ng-app="app" data-ng-controller="myCtrl">
<h3>CKEditor 4.2:</h3>
<div ng-repeat="editor in ckEditors">
<textarea data-ng-model="editor.value" maxlength="50" data-ck-editor></textarea>
<br />
</div>
<button ng-click="addEditor()">New Editor</button>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本
var app = angular.module('app', []);
app.directive('ckEditor', [function () {
return {
require: '?ngModel',
link: function ($scope, elm, attr, ngModel) {
var ck = CKEDITOR.replace(elm[0]);
ck.on('pasteState', function () {
$scope.$apply(function () {
ngModel.$setViewValue(ck.getData());
});
});
ngModel.$render = function (value) {
ck.setData(ngModel.$modelValue);
};
}
};
}])
function myCtrl($scope){
$scope.ckEditors = [{value: ''}];
}
Run Code Online (Sandbox Code Playgroud) 我使用cropper.js创建了一个用于裁剪图像的应用程序,应用程序正在运行并且图像正在裁剪但我无法看到预览,我的预览div在裁剪时没有正确填充任何内容.我的代码如下所示
任何人都可以告诉我一些解决方案
脚本
var $image = $('.img-container > img'),
$dataRotate = $('#dataRotate'),
options = {
modal: true,
guides: true,
autoCrop: false,
dragCrop: true,
movable: true,
resizable: true,
zoomable: false,
touchDragZoom: false,
mouseWheelZoom: false,
preview: '.preview',
crop: function (data) {
$dataRotate.val(Math.round(data.rotate));
}
};
Run Code Online (Sandbox Code Playgroud) 任何人都可以告诉我如何做一个区分大小写的过滤器而不使用angularjs中的用户定义的过滤器,看到这里我想打印所有的名称除外john,但当我把filter:{item: '!john'}它删除john,johnmathew以及johnny,但我只john需要删除.
HTML
<div ng-app='myApp' ng-controller="Controller">
<div ng-repeat="val in items | filter:{item: '!john'}">{{val.item}}</div>
</div>
Run Code Online (Sandbox Code Playgroud)
脚本
var app = angular.module('myApp', []);
app.controller('Controller', function ($scope) {
$scope.items = [{
item: 'john'
}, {
item: 'sunny'
}, {
item: 'johnmathew'
}, {
item: 'lenu'
}, {
item: 'binu'
}, {
item: 'johnny'
}];
});
Run Code Online (Sandbox Code Playgroud)
如何为Rectangular编写茉莉花测试,如下所示
脚本
$scope.allEmployees = [{
visible: true,
empId: "EMP148"
}];
$scope.employeeDocuments = { "EMP148": [{
"empId": "EMP148",
"department": "Sales",
"firstName": "Manu",
"lastName": "Mathew",
"place": "Kolkata"
}]
};
var employeesCopy = angular.copy($scope.allEmployees);
$scope.allEmployees.push({visible: true, empId: "EMP489"});
$scope.addEmployees = function (employeesCopy) {
var newEmployee = {visible: true, empId: "EMP489"};
var emplyeeList = {
employees: $scope.allEmployees,
newEmployee: newEmployee
};
Restangular.all('emp/getEmployees').post(emplyeeList).then(function (employees) {
if (!_.isEmpty(employees[emplyeeList.newEmployee.empId])) {
if ($scope.employeeDocuments.hasOwnProperty(emplyeeList.newEmployee.empId)) {
delete $scope.employeeDocuments[emplyeeList.newEmployee.empId];
}
$scope.employeeDocuments[emplyeeList.newEmployee.empId] = employees[emplyeeList.newEmployee.empId];
setMyEmployees(true);
$scope.flag = true;
console.log("success");
} else {
$scope.employeeDocuments …Run Code Online (Sandbox Code Playgroud) 我所看到的BiConsumer,BiPredicate,BiFunction但不能BiSupplier或类似。我尝试了下面的代码,但有一个异常说:
“在 BiSupplier 中发现的多个非覆盖抽象方法”。
@FunctionalInterface
public interface BiSupplier<T, R> {
/**
* Gets a first.
*
* @return a first
*/
T getFirst();
/**
* Gets a second.
*
* @return a second
*/
R getSecond();
}
Run Code Online (Sandbox Code Playgroud)
可以请一些人帮我解决这个问题。
我已经创建了一个应用程序是angularjs,其中我有一个指令,我正在指令中的一个监视器,当$ rootScope变量发生更改时触发指令中的某些方法,但问题是当$ rootScope.name值被更改指令内的手表不起作用
我的代码如下所示
var module = angular.module('myapp', []);
module.controller("TreeCtrl", function($scope, $rootScope) {
$scope.treeFamily = {
name : "Parent"
};
$scope.changeValue = function()
{
$rootScope.name = $scope.userName;
};
});
module.directive("tree", function($compile) {
return {
restrict: "E",
transclude: true,
scope: {},
template:'<div>sample</div>',
link : function(scope, elm, $attrs) {
function update()
{
};
scope.$watch('name', function(newVal, oldVal) {
console.log('calling');
update();
}, true);
}
};
});
Run Code Online (Sandbox Code Playgroud) 我为下拉框创建了一个angularjs指令,该指令工作正常,但问题是当我复制指令时,两者同时打开,选择和关闭
<div ng-app='myApp' ng-controller="Controller">
<drop-down></drop-down>
<br> <br> <br> <br> <br> <br>
<drop-down></drop-down>
</div>
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我一些解决方案
我有两个函数调用 Employee 和 Address DAO 类,我在其中检查员工姓名或地址是否已被使用
为了使检查和抛出异常通用,我创建了以下通用函数
checkOrElseThrow在CommonUtil.java
public static <R, C, T extends Throwable> R checkOrElseThrow(R rtn, C chk, Supplier<? extends T> ex) throws T
{
if (chk != null)
{
throw ex.get();
}
return rtn;
}
Run Code Online (Sandbox Code Playgroud)
上面的通用函数在EmployeeDAO.java和AddressDAO.java 中被调用,如下所示
checkAndReturnEmployee在EmployeeDAO.java
public Employee checkAndReturnEmployee(Employee employee) {
return checkOrElseThrow(
employee,
employee.getAddressName(),
() -> new EntityNotFoundException("Employee already in use for another address"));
}
Run Code Online (Sandbox Code Playgroud)
checkAndReturnAddress在AddressDAO.java
public Address checkAndReturnAddress(Address address) {
return checkOrElseThrow(
address, …Run Code Online (Sandbox Code Playgroud) public void setQueryTimeout(int queryTimeout)我想知道我们需要传入的值的类型是什么jdbcTemplate。文件说
> Set the query timeout for statements that this JdbcTemplate executes.
> <p>Default is -1, indicating to use the JDBC driver's default (i.e. to
> not pass a specific query timeout setting on the driver). <p>Note: Any
> timeout specified here will be overridden by the remaining transaction
> timeout when executing within a transaction that has a timeout
> specified at the transaction level. @see
> java.sql.Statement#setQueryTimeout
Run Code Online (Sandbox Code Playgroud)
想知道queryTimeout是否是milliseconds, …
我看到很多人@Autowired在构造函数中使用注释来注入依赖项,如下所示
@Service
public class Employee {
private EmployeeService employeeService;
@Autowired
public Employee(EmployeeService employeeService) {
this.employeeService = employeeService;
}
:
:
}
Run Code Online (Sandbox Code Playgroud)
据我所知,现在 Spring 非常先进,Spring 构造函数/setter DI 即使没有@Autowired如下所示也能工作
@Service
public class Employee {
private EmployeeService employeeService;
public Employee(EmployeeService employeeService) {
this.employeeService = employeeService;
}
:
:
}
Run Code Online (Sandbox Code Playgroud)
想知道人们是否有任何理由使用@Autowired注释来注释构造函数以注入依赖项。
有人可以帮我解决这个问题吗
angularjs ×5
javascript ×5
java ×4
java-8 ×3
jquery ×2
lambda ×2
supplier ×2
autowired ×1
ckeditor ×1
crop ×1
image ×1
jasmine ×1
jdbc ×1
jdbctemplate ×1
maxlength ×1
restangular ×1
spring ×1
throwable ×1
unit-testing ×1
watch ×1