Tag: angularjs

专注于ng-repeat生成的输入

HTML代码 角度代码 $scope.data = { forms: [] }; jQuery(document).ready(function() { setTimeout(function() { jQuery(‘#search_0’).focus(); }, 500); }); 上面的代码有效,但需要额外的setTimeout。 有没有更好的方法等待生成表单然后执行focus()?

angular js ng-从范围重复单选按钮列表,并选中默认值

app.controller(‘radiusController’, function($scope){ $scope.radii = [ {id:.25, checked:”false”, name:”1/4 Mile”}, {id:.5, checked:”false”, name:”1/2 Mile”}, {id:1, checked:”false”, name:”1 Mile”}, {id:2, checked:”true”, name:”2 Mile”}, {id:3, checked:”false”, name:”3 Mile”}, {id:4, checked:”false”, name:”4 Mile”}, {id:5, checked:”false”, name:”5 Mile”} ]; $scope.handleRadioClick = function(radius){ window.radiochecked = radius.id; }; }); {{radius.name}} 如何根据范围半径的选中值设置要检查的默认单选按钮? 在这种情况下,默认情况下应检查“2英里”。 plunker: http ://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p = preview

ng-if如果不比较ng-repeat中的$ index

在我的代码中,我想只打印数组中的第一个单词 ,而我正在使用ng-if条件。 HTML: {{Word}}- {{$index}} 控制器: var myApp = angular.module(‘myApp’, []); function MyCtrl($scope) { $scope.Words = [‘Mon’,’Tue’,’Wed’]; } 正如你所看到我使用ng-if=”$index === 0″然后打印div值但它想要工作,不知道为什么? 示例: http : //jsfiddle.net/kevalbhatt18/twvy0j4a/3/

在角度选择菜单中显示预选项目?

我的应用程序中有一个selectize-ng输入: 我的控制器是 $scope.users = []; UsersWithRolesFactory.getUserRoleData().then(function(response) { $scope.users = response; }); $scope.usersSelect = { options: { valueField: ‘full_name’, labelField: ‘full_name’, searchField: [‘full_name’], plugins: [‘remove_button’] } }; 我的(部分)json数据是 [{“id”:17,”full_name”:”Janet Willis”,”selected”:false,”merchant”:”Geba”,”role”:”Reviewer”}, {“id”:18,”full_name”:”Michelle Murphy”,”selected”:false,”merchant”:”Zazio”,”role”:”Reviewer”}, {“id”:19,”full_name”:”Carol Gardner”,”selected”:true,”merchant”:”Skinte”,”role”:”User”}, {“id”:20,”full_name”:”Laura Wallace”,”selected”:false,”merchant”:”Yacero”,”role”:”User”}] 我需要做的是显示被selected:true的用户selected:true在该字段中为selected:true ,例如Carole Gardner(在现场手动输入): 这是怎么做到的?

如何在猫头鹰旋转木马的角度制作指令?

你可以告诉我如何在角度js中制作dirctive。我需要在js中使用owl carousel插件,就像我在jqm小提琴中所做的那样http://jsfiddle.net/ezanker/o9foej5L/1/ 。我需要做同样的事情你可以告诉我如何实现这个使用指令http://plnkr.co/edit/4ySYwsqrBKUJUj6MwoRY?p=catalogue one two three four

强制角度在Mac OS上使用Safari重新进入历史记录中的控制器

我有以下控制器在页面加载时执行并更改提交按钮的值和状态。 这里可以看到完整的例子,并且基于这个问题。 app.controller(‘FormSubmitCtrl’, function($scope, $rootScope, $timeout) { $scope.loading = false; $scope.load = function($event) { $rootScope.event_target = $event.target; $scope.loading = true; $timeout(function() { $scope.loading = false; }, 5000); } }); app.directive(‘disabler’, function($compile, $rootScope) { return { link: function(scope, elm, attrs) { //var btnContents = $compile(elm.contents())(scope); scope.$watch(attrs.ngModel, function(value) { if (value) { scope.initial_value = elm.attr(‘value’); if (elm.attr(‘name’) […]

使用angularjs为默认值分配多选下拉列表

我正在使用这个插件http://dotansimha.github.io/angularjs-dropdown-multiselect/#/ 如果您查看此页面中的演示部分,请使用“智能按钮文本”演示,因为我正在使用它。 在此演示中,如果您选择任何用户,这些名称将显示在栏中。 现在,我想给它默认值。 因此,只要页面加载,此多选下拉列表中就会出现默认值。 在正常情况下,我可以使用ng-init。 在这种情况下我该怎么办? 请有人在这里说清楚……

html2canvas和toDataURL生成的图像有水平线

我循环遍历10-14个html元素,并在数组中生成图像数据,以便以后用于插入PDF。 问题是这些图像偶尔会有一条水平线,这似乎是html2canvas的一个现存问题。 主要发生在FF和IE中,而且发生在Chrome上,但不常见。 function convertElementsToImages(containerSelector) { if (_this.pdfDebug) { window.console.log(‘convertElementsToImages’); window.console.log(containerSelector); } var eles = $(containerSelector + ‘ > *’), q = $q.defer(), temp = []; //convert to canvas angular.forEach(eles, function(ele, eleKey) { convertElementToImage(ele).then(function(imageData) { temp[eleKey] = imageData; //last one, hopefully all previous elements have been resolved if (eles.length === eleKey + 1) { q.resolve(temp); […]

将路由从状态提供者转换为路由提供者

我在config.JS上有以下代码,它完全正常: function config($stateProvider, $urlRouterProvider, $ocLazyLoadProvider, IdleProvider, KeepaliveProvider, adalAuthenticationServiceProvider, $httpProvider) { // Configure Idle settings IdleProvider.idle(5); // in seconds IdleProvider.timeout(120); // in seconds $urlRouterProvider.otherwise(“/dashboards/dashboard_1”); $ocLazyLoadProvider.config({ // Set to true if you want to see what and when is dynamically loaded debug: true }); $stateProvider .state(‘dashboards’, { abstract: true, url: “/dashboards”, templateUrl: “views/common/content.html”, }) .state(‘dashboards.dashboard_1’, { url: […]

在History popstate事件中获取AngularJs $范围?

我是新手angularjs开发者。 我有, var app = angular.module(‘myapp’, []); app.controller(‘ProductCtrl’, [‘$scope’, ‘$sce’, function ($scope, $sce) { $scope.products = myapp.products; $scope.pager = $sce.trustAsHtml(myapp.pager); $scope.getProducts = function($event) { $event.preventDefault(); var $link = $($event.target); var url = $event.target.href; $.getJSON(url, function(response) { $scope.$apply(function() { $scope.products = response.products; $scope.pager = $sce.trustAsHtml(response.pager); }); history.pushState(response, “Index”, url); }); }; }]); $(window).bind(“popstate”, function (e) { […]