angularjs-directive

ng-options with a dynamic expression is not working

不问归期 提交于 2019-12-25 04:44:42
问题 I'm trying to create a directive in angular, to replace the regular dropdown. I need to be able to set a dynamic expression to ng-options but doesn't seem to be working inside the directive. It works perfectly outside it. This is the directive angular.module('app.dropdown',[]) .directive('swDropdown',[ function ( ){ return { restrict: 'E', replace: true, template:'<div><select ng-model="swModel" ng-options="{{expression}}" ></div>', link: link, scope:{ swOptions:"=", swLabel:'@', swValue:'@',

ngOptions: add tooltip to selection

蓝咒 提交于 2019-12-25 04:27:21
问题 using the following json collection: $scope.searchscope = [ { id: 0, name: "Base", description: "Search only the specified base object. The value is equal to 0." }, { id: 1, name: "OneLevel", description: "Search the child objects of the base object, but not the base object itself.The value is equal to 1" }, { id: 2, name: "Subtree", description: "Search the base object and all child objects. The value is equal to 2" } ]; and the following markup <select data-ng-model="mySelections[0]

ngOptions: add tooltip to selection

让人想犯罪 __ 提交于 2019-12-25 04:27:19
问题 using the following json collection: $scope.searchscope = [ { id: 0, name: "Base", description: "Search only the specified base object. The value is equal to 0." }, { id: 1, name: "OneLevel", description: "Search the child objects of the base object, but not the base object itself.The value is equal to 1" }, { id: 2, name: "Subtree", description: "Search the base object and all child objects. The value is equal to 2" } ]; and the following markup <select data-ng-model="mySelections[0]

css update on resize with angularjs

六月ゝ 毕业季﹏ 提交于 2019-12-25 04:17:20
问题 I am trying to make a div that is a square, initialised at a width and a height of 25% of the width of the page. I want that the size of the div gets updated everytime i resize the browser to the right width and height. What am i doing wrong? 'use strict' angular.module("cars4export.directives", []).directive('box', function($window) { return { restrict: "C", link: function(scope, element, attrs) { var width = $window.innerWidth * 0.25; //initialising element.css({ width: width, height: width

How to communicate between controllers while not using SharedService between them?

跟風遠走 提交于 2019-12-25 03:55:35
问题 I was reading all the answers about communication between controllers and directive, but is seems to me occurred using shared service and inject it to each one of them. When I'm developing a very large scale application, I don't know what my page is going to have in it. I may have 2 controllers need to communicate between them, and I also may have 5 directive and 2 controllers in the same page. I don't know from scratch what is going to be inside my view/page, so I need a better way how to

How to communicate between controllers while not using SharedService between them?

微笑、不失礼 提交于 2019-12-25 03:55:03
问题 I was reading all the answers about communication between controllers and directive, but is seems to me occurred using shared service and inject it to each one of them. When I'm developing a very large scale application, I don't know what my page is going to have in it. I may have 2 controllers need to communicate between them, and I also may have 5 directive and 2 controllers in the same page. I don't know from scratch what is going to be inside my view/page, so I need a better way how to

How do you rotate text values in Angular?

江枫思渺然 提交于 2019-12-25 03:27:28
问题 Completely new to Angular and I can think of 100 different ways to accomplish this outside of Angular, but pushing myself to learn the Angular ways. My goal, I have an element that has plain text in it. I want to rotate that text every x seconds. Here's the base HTML: <h2>Rotating text in Angular is <span>fun</span></h2> The span is where I want the text to rotate from fun to 'sucks', 'awesome', 'hard', 'easy' every x number of seconds. A nice transition will also be included, but looking for

$location.search is not updated imediatly

余生长醉 提交于 2019-12-25 03:26:10
问题 I have a problem that my url doesn't get updated every time i set it. It is somehow connected with the directive, because in other cases it works. So my question is, on what is the $location.search('dd', val) depended on, what is it waiting for, because function gets called, but the url is not updated. 回答1: it waits for a digest.. $scope.$apply(function() { $location.search('dd', val) }) 来源: https://stackoverflow.com/questions/24572613/location-search-is-not-updated-imediatly

AngularJS: how to compile form in a directive

主宰稳场 提交于 2019-12-25 02:52:57
问题 I'm trying to create a custom directive that set 'required' and 'disabled' attributes to the element (form input). The directive gets this data from the scope object. But clearing of required field doesn't set my form to invalide state. I think it's about form compilation after changing the attribute. I tried to do that but got an infinite loop :( How to compile my form correctly? Here is plunker 回答1: You could just use ng-disabled and ng-required , instead of adding the attributes in a

Angular.js directive template using variable from parent/inherited scope

会有一股神秘感。 提交于 2019-12-25 01:59:46
问题 I want to chose directives templateUrl depending on some variable from its parent scope. I can't use templateUrl function, since it doesn't have a scope yet. I can $compile the template from $templateCache(note that it's already there, I'm not loading it) from inside the linking function, but I am afraid it's gonna have a negative impact on performance(let say this is a table cell directive.. and there's quite a few cells). Do I have any other, better option? 回答1: There is indeed no other way