directive

Directive to hide/show element for authenticated user

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What is the correct way to hide/show elements in custom directive handler? In my application I have number of elements which should be hidden/shown based on user authentication state. To track the state I created 'Auth' service. At the moment I'm concerned that 'Auth' service is injected almost into each controller. To avoid this I decided that it would be better to create a directive which will show/hide elements based on 'Auth' service state. Something like <div data-app-auth-only="true">Content is visible only for authenticated users</div

Link vs compile vs controller

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When you create a directive, you can put code into the compiler, the link function or the controller. In the docs, they explain that: compile and link function are used in different phases of the angular cycle controllers are shared between directives However, for me it is not clear, which kind of code should go where. E.g.: Can I create functions in compile and have them attached to the scope in link or only attach functions to the scope in the controller? How are controllers shared between directives, if each directive can have its own

bxslider directive throwing error `Uncaught TypeError: Cannot read property &#039;indexOf&#039; of undefined`

匿名 (未验证) 提交于 2019-12-03 08:51:18
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using angularjs in my application where I have created a directive for bxslider. Below is code of directive: angular.module('sbAdminApp') .directive('bxSlider', function(){ return{ restrict: "A", require: "ngModel", link: function(scope, element, attrs, ctrl){ element.ready(function(){ $($(element[0])).bxSlider({ maxSlides:1, auto:true, controls:false, pager:true }); }) } } }) Above I am using like this $($(element[0])).bxSlider({ after ready function as I search for a problem where bxslider should work with ng-repeat and found this

Difference in scope between directive with template and without template AND between Angular 1.2 and 1.1?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am new to Angular and trying to understand advanced directive API - I want to re-create directive template in compile function using directive element attributes. But when I don't have a template set (or template is empty string) instead accesing isolated directive scope I access parent (controller) scope. Also - this works on Angular 1.1 but not 1.2 here is HTML: <div class="container" ng-app="app" ng-controller="AppController"> <sandbox title="Attribute Title"></sandbox> </div> JavaScript: var app = angular.module('app', [], function ()

antisamy parser force closing tag

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use Antisamy for validating HTML. My policy allow iframes, like youtube videos. Problem is - if tag is empty(like this): <iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen></iframe> than after cleaning it will be like this: <iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen/> But it should have normal closing tag. And this break all content on page after. I already set my directives to use most of HTML but not XML: <directives> <directive name=

Datepicker angular directive for Bootstrap not showing

匿名 (未验证) 提交于 2019-12-03 08:42:37
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my Angular project I am trying to use the Angular directives for bootstrap datepicker , but it isn't showing up. I've linked to <script src="bower_components/angular-bootstrap/ui-bootstrap.js"></script> and <script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script> in my index.html and in my app.js I've put ui.bootstrap as a dependency. angular .module('myApp', ['ui.bootstrap']) Is there anything obvious I am missing? I am trying to use uib-datepicker-popup within a ng-switch within a ng-repeat, but I don't see why

How to inject a controller into a directive when unit-testing

南楼画角 提交于 2019-12-03 03:57:08
I want to test an AngularJS directive declared like this app.directive('myCustomer', function() { return { template: 'cust.html' controller: 'customerController' }; }); In the test I would like to inject (or override) the controller, so that I can test just the other parts of the directive (e.g. the template). The customerController can of course be tested separately. This way I get a clean separation of tests. I have tried overriding the controller by setting the controller property in the test. I have tried injecting the customController using $provide . I have tried setting ng-controller on

nginx: [emerg] “http” directive is not allowed here in /etc/nginx/sites-enabled/default:1

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm new to NGINX and I'm trying to setup minimal working thing. So I trying to run aiohttp mini-app with nginx and supervisor (by this example). But I can't configure Nginx right and getting the following error: nginx: [emerg] "http" directive is not allowed here in /etc/nginx/sites-enabled/default:1 Here is full default.conf file: http { upstream aiohttp { # Unix domain servers server unix:/tmp/example_1.sock fail_timeout=0; server unix:/tmp/example_2.sock fail_timeout=0; server unix:/tmp/example_3.sock fail_timeout=0; server unix:/tmp

How to create an angularJs wrapper directive for a ui-bootstrap datepicker?

匿名 (未验证) 提交于 2019-12-03 02:49:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the ui.bootstrap.datepicker directive to display some date field. However most of the time I need the same setup: I want it to come along with a popup and a popup button and also I want German names for the texts. That does create the same code for the button and the texts and the formatting over and over again, so I wrote my own directive to prevent myself from repeating myself. Here is a plunkr with my directive. However I seem to be doing it wrong. If you choose a date with the date picker using the "Date 1" datepicker that

AngularJS error: Template for directive &#039;XXXXXX&#039; must have exactly one root element

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This is a follow-up to this question . I am trying to build and HTML <table> with multiple <tr> rows. I want some of these rows to be rendered by my directive myDirectiveA and others to be rendered by my directive 'myDirectiveB'. Below you can see what my files look like. It all works fine if there is only one <tr> row in the file path/to/myDirectiveA.template.html . But as soon as I add another row in there, I get the following error: `angular.js:13920 Error: [$compile:tplrt] Template for directive 'myDirectiveA' must have exactly one root