HTML源代码
<div ng-app="">
<div ng-controller="test">
<div ng-address-bar browser="html5"></div>
<br><br>
$location.url() = {{$location.url()}}<br>
$location.search() = {{$location.search('keyword')}}<br>
$location.hash() = {{$location.hash()}}<br>
keyword valus is={{loc}} and ={{loc1}}
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
AngularJS源代码
<script>
function test($scope, $location) {
$scope.$location = $location;
$scope.ur = $scope.$location.url('www.html.com/x.html?keyword=test#/x/u');
$scope.loc1 = $scope.$location.search().keyword ;
if($location.url().indexOf('keyword') > -1){
$scope.loc= $location.url().split('=')[1];
$scope.loc = $scope.loc.split("#")[0]
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
这里变量loc和loc1返回测试作为上述URL的结果.这是正确的方法吗?
我正在使用angular-translate将页面内容翻译成不同的语言.
<input type ='text' placeholder = ' {username | translate}'>
Run Code Online (Sandbox Code Playgroud)
这在页面加载时工作正常..但是当我$translate.uses('fr')根据语言下拉列表更改使用时它无法翻译.
任何人都可以建议在语言动态变化时翻译占位符的解决方案吗?
angular.directive('ppd:reset', function(e1,e2) {
return function(linkElement) {
linkElement.wrap()....
});
};
});
Run Code Online (Sandbox Code Playgroud)
和
angular.directive('ppd:reset', [function() {
return function(scope, elm, attrs) { }
}]);
Run Code Online (Sandbox Code Playgroud)
这两个指令模式有什么区别?
如何将jquery的以下函数迁移到angular js?
$( "#foo" ).trigger( "click" );
Run Code Online (Sandbox Code Playgroud)
这里的问题是我计划在用户填写我们的应用程序中的某些数据时自动触发提交按钮.
所以我从jquery背景,
提前致谢.
题 :
如何将默认值设置为角度ui-select
从对象和对象获取的下拉值不具有默认值.
和ui-select应该在前端设置默认值.
例如:
下拉值如下
1 -all fruits 2 -apple 3 -banana 4-water melon
从2到4的值是从服务器发送的对象派生的.但是前端需要设置默认值,即1 - 所有水果
通过ui-select2参考下面的示例集如何在ui-select中迁移它?
<select ng-model="fID" class="select" ui-select2 data-placeholder="select fruit">
<option value="">All fruits</option>
<option ng-repeat="f in frits value="{{f.fID}}">{{f.name}}</option>
</select>
<ui-select theme="select2" ng-model="fruits.selected">
<ui-select-match placeholder="select please" allow-clear="false"> {{$select.selected.name}}
</ui-select-match>
<ui-select-choices repeat="f in fruits | filter:$select.search">
<div ng-bind-html="f.name | highlight: $select.search:'underline'"></div>
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
http://plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview https://github.com/angular-ui/ui-select 链接:angular-ui/ui-select
角度版本:AngularJS v1.3.6 http://github.com/angular-ui/ui-select:版本:0.8.3
var p1 = {name:'Ramesh',email:'Ramesh@email.com',年龄:99};
$scope.people = [
{ name: 'Amalie', email: 'amalie@email.com', age: 12 },
{ name: 'Wladimir', email: 'wladimir@email.com', age: 30 },
{ name: 'Samantha', email: 'samantha@email.com', age: 31 },
{ name: 'Estefanía', email: 'estefanía@email.com', age: 16 },
{ name: 'Natasha', email: 'natasha@email.com', age: 54 },
{ name: 'Adrian', email: 'adrian@email.com', age: 21 },
p1
];
$scope.people.selected = p1 ;
Run Code Online (Sandbox Code Playgroud)
HTML:
<ui-select class="full-width-select select" ng-model="people.selected" theme="select2">
<ui-select-match allow-clear="false">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="person in people | filter:$select.search"> …Run Code Online (Sandbox Code Playgroud)这是一个我想与ng-repeat一起使用的对象,但是它无法看到内部firstlang属性:
$scope.school{
name : "stackoverflow",
sub :{
firstlang : "kannada"
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的重复:
<ul>
<li ng-repeat="index in school.sub">
first language is = {{index.firstlang}}
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
期望的结果是: first language is = kannada
问题:当我在显示和隐藏密码之间切换时,输入的formControlName'密码'值不会反映出来.
流程:
我的观点部分:
<ion-input formControlName="password" placeholder="Password*" type="password" (ngModelChange)="onChange($event)"
autocomplete="off" [hidden]="showPasswordModel"></ion-input>
<ion-input formControlName="password" placeholder="Password-" type="text" (ngModelChange)="onChange($event)"
autocomplete="off" [hidden]="!showPasswordModel"></ion-input>
<ion-item class="checkbox-container">
<ion-label>Show password</ion-label>
<ion-toggle (click)="showPasswordModel = !showPasswordModel"></ion-toggle>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
ts部分
constructor(private _formBuilder:FormBuilder) {
this.loginForm = this._formBuilder.group({
password: ['', Validators.compose([Validators.required])]
});
--
}
Run Code Online (Sandbox Code Playgroud)
提示:http://blog.ng-book.com/the-ultimate-guide-to-forms-in-angular-2/
提前致谢
var f = function() {
this.m = '10' ;
f1 = function(){
alert(m)
}
}
o = new f()
o.m
f1()
Run Code Online (Sandbox Code Playgroud)
这是从上面的例子调用嵌套函数f1的正确方法
Lib链接:https://github.com/angular-ui/ui-select
有没有办法在multiSelect中阻止用户编辑?
我想允许用户只清除以前选择的数据,但是如何阻止他输入ui-select中的任何自由文本
http://plnkr.co/edit/juqoNOt1z1Gb349XabQ2?p=preview
<ui-select multiple ng-model="multipleDemo.colors" theme="select2" ng-disabled="disabled" style="width: 300px;">
<ui-select-match placeholder="Select colors...">{{$item}}</ui-select-match>
<ui-select-choices repeat="color in availableColors | filter:$select.search">
{{color}}
</ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)
参考上面的代码和plunker,目前在ui-select"蓝色,红色"颜色被选中,用户可以清除这些值,但如果用户试图在ui中输入一些文本,请选择允许修改,
"但我的要求是阻止用户在该字段中输入此类文本."
提前致谢.
angularjs ×8
javascript ×5
ui-select ×3
ui-select2 ×2
angular ×1
ionic2 ×1
jquery ×1
reactive ×1
routeparams ×1
translate ×1