$(document).ready(function () {
$("#toggle").click(function () {
if ($(this).data('name') == 'show') {
$("#sidebar").animate({
width: '10%'
}).hide()
$("#map").animate({
width: '89%'
});
$(this).data('name', 'hide')
} else {
$("#sidebar").animate({
width: '29%'
}).show()
$("#map").animate({
width: '70%'
});
$(this).data('name', 'show')
}
});
});Run Code Online (Sandbox Code Playgroud)
html, body {
width:100%;
height: 100%;
}
#header {
width: 100%;
height: 20%;
float: left;
border: 1px solid;
}
#map {
width: 80%;
height: 80%;
float: left;
border: 1px solid;
}
#sidebar {
width: 19%;
height: 80%;
float: left;
border: 1px solid;
} …Run Code Online (Sandbox Code Playgroud)在这里,我创建了自动完成的示例,它工作正常,我需要对此进行一些修改.目前它的工作方式是这样的
任何人都可以帮忙吗?谢谢
var app = angular.module('app', ['ui.bootstrap']);
app.controller('TypeaheadCtrl', function ($scope, $http, limitToFilter, filterFilter) {
$scope.sample_data = [{
"name": "Nelson",
"designation":"Senior Developer",
"company": "acme",
"companydisplay": "abc"
},
{
"name": "suresh",
"designation":"Developer",
"company": "acme",
"companydisplay": "def"
},
{
"name": "Naresh",
"designation":"Developer",
"company": "acme",
"companydisplay": "xyz"
}];
$scope.filtered_sample_data = function (search) {
var filtered = filterFilter($scope.sample_data, search);
var results = _(filtered)
.groupBy('company')
.map(function (g) {
g[0].initial = true; // the first item in each group
return g;
})
.flatten()
.value();
return results; …Run Code Online (Sandbox Code Playgroud)javascript angularjs angularjs-directive angularjs-scope angularjs-controller
在下面的示例中,我添加了一些示例文件,工作正常,但我需要对此进行一些修改.目前在验证时,它显示如下错误:
但我需要它做的是显示一个工具提示.工具提示需要自动弹出并保持可见,直到错误被清除.像这样:

$('#myForm').validator()Run Code Online (Sandbox Code Playgroud)
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="https://1000hz.github.io/bootstrap-validator/dist/validator.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<form data-toggle="validator" role="form">
<div class="form-group">
<label for="inputName" class="control-label">Name</label>
<input type="text" class="form-control" id="inputName" placeholder="Cina Saffary" required>
</div>
<div class="form-group has-feedback">
<label for="inputTwitter" class="control-label">Twitter</label>
<div class="input-group">
<span class="input-group-addon">@</span>
<input type="text" pattern="^[_A-z0-9]{1,}$" maxlength="15" class="form-control" id="inputTwitter" placeholder="1000hz" required>
</div>
<span class="glyphicon form-control-feedback" aria-hidden="true"></span>
<span class="help-block with-errors">Hey look, this one has feedback icons!</span>
</div>
<div class="form-group">
<label for="inputEmail" class="control-label">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email" data-error="Bruh, that email address is invalid" required>
<div class="help-block with-errors"></div>
</div> …Run Code Online (Sandbox Code Playgroud)我试图将值从一个模块传递到angularjs中的另一个模块.使用.value工作正常.
工作: -
var app = angular.module('app', []);
app.value('movieTitle', 'The Matrix');
var app1 =angular.module('app1', ['app']);
app1.controller('MyController', function (movieTitle) {
//Here I am getting value. which is working fine.
console.log(movieTitle)
})
Run Code Online (Sandbox Code Playgroud)
不工作: -
var app = angular.module('app', []);
app.value('movieTitle', 'The Matrix');
app.controller('MyController', function (movieTitle) {
//Here I override the value.
movieTitle = "The Matrix Reloaded";
})
var app1 =angular.module('app1', ['app']);
app1.controller('MyController', function (movieTitle) {
//Here I am getting old value not update value.
console.log(movieTitle)
})
Run Code Online (Sandbox Code Playgroud)
在第二个示例中,我尝试更新其更新的值.但是当Am访问其他模块的值时,它只显示旧值未更新,任何人都可以帮助我.哪里我错了...
我正在创建一个动态表单,根据来自 JSON 之类的响应动态填充字段。
例如:-
[{
"type":"text",
"required":true,
"minlength": 3,
"maxlength":5,
"name":"fname",
"visibility":true
},
{
"type":"text",
"required":true,
"minlength": 3,
"maxlength":5,
"name":"lname",
"visibility":"fname == 'abc' || fname == 'xyz'"
},
{
"type":"text",
"required":true,
"minlength": 3,
"maxlength":5,
"name":"fid",
"visibility":true
},
{
"type":"text",
"required":true,
"minlength": 3,
"maxlength":5,
"name":"lid",
"visibility":"fid == 1 || fid == 4"
}]
Run Code Online (Sandbox Code Playgroud)
我有一个用例,只有当第一个字段的值应该为“abc”或“xyz”时,第二个字段才应该可见(条件写在 JSON 属性中)。如何动态实现?