angularjs-directive

angular.js directive templateUrl fails to bind scope

对着背影说爱祢 提交于 2019-12-12 11:20:16
问题 I'm creating a directive that will display and show content by listening to the $routeChangeError event on $rootScope. I got it all to work by inlining the template like this: app.directive("alert", function ($rootScope) { 'use strict'; return { restrict: "E", replace: true, template: '<div class="alert alert-warning alert-dismissable" ng-show="isError">' + '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + '{{ message }}' + '</div>', //templateUrl:

AngularJS - access directive scope from transclude scope

孤街醉人 提交于 2019-12-12 11:17:39
问题 I have a directive with some form. Usually it is all I need, but sometimes I need to add some more input fields. So I tried to use transclusion for that, but it doesn't work. I created a plunker to ilustrate that: http://plnkr.co/edit/zNOK3SJFXE1PxsvUvPBQ?p=preview Directive is a simple form with input field, transclusion and a button to help testing it (not important parts ommitted): scope: { }, transclude: 'element', template: '<form name="myForm">' + '<input type="text" ng-model="data

How to run protractor?

匆匆过客 提交于 2019-12-12 11:13:47
问题 I'm very new to protractor. I am running this in Windows command line. I followed the this tutorial https://github.com/angular/protractor/blob/master/docs/getting-started.md I sucessfully run npm install -g protractor I don't know how to run this node_modules/protractor/bin/install_selenium_standalone If I run this straight away in command line. I am getting this error 'node_modules\protractor\bin\install_selenium_standalone' is not recognized as an internal or external command, operable

AngularJS on enter directive on form input no saving Model value

寵の児 提交于 2019-12-12 11:07:00
问题 I have the following on a page - full code in this Plunker There is a custom onEnter directive that calls a function when enter is pressed on a chat form input. Code snippet below //**HTML View** <div ng-controller="mainCtrl"> <ul> <li ng-repeat="chat in chatMessages"> {{chat.username}}<br/> {{chat.message}} </li> </ul> </div> <form id="chatForm" name="chatForm" ng-controller="formCtrl"> <label for="chat-username">User: </label> <input type="text" id="chat-username" class="chat__username" ng

angularjs directive with ng-if in the template

别说谁变了你拦得住时间么 提交于 2019-12-12 10:50:15
问题 I'm building a directive that utilizes an ng-if inside of it's template. What's strange is that the element provided to the link function does not have the ng-if code expanded, it is only a comment line for the ng-if. Playing around, I found that by wrapping my link code in a $timeout seems to get it to work, but I am wondering if that is not the correct way of going about it....and more so, why is this happening. I've added a plunk to demonstrate: http://plnkr.co/edit/Gl7v8yJLevi664nUKcFY?p

How to use two events onItemSelect and onItemDeselect in AngularJS Dropdown Multiselect

北城以北 提交于 2019-12-12 10:36:50
问题 I am using AngularJS Dropdown Multiselect. http://dotansimha.github.io/angularjs-dropdown-multiselect/#/ And I want to use both the events. But don't know how to configure both. I am able to configure only one of them successfully. onItemSelect(property) and onItemDeselect(property) HTML <div ng-dropdown-multiselect="" options="property.dropdowns" selected-model="property.propertyValues" extra-settings="multiSelectDropdownSettingsMaxOne" ng-required="property.startDate != null" events=

How to arrange titles around a `oval` shape by `even` and `odd` values based

半世苍凉 提交于 2019-12-12 10:20:44
问题 I am working in angular application. i have a scenario here, when i am getting the titles from back-end the client requires that to be arranged around a oval (it contains some image) and when the tiles length are odd then the firs element ( balance ) should be in the top. rest of the titles need to arrange the both side of the oval . when i am getting the title length as even there is no need to keep the title in the top. i tried some point. but i didn't get any valuable output. my be the way

How multiple ng-app works in angular

China☆狼群 提交于 2019-12-12 10:16:53
问题 I tried giving two ng-app in an application , when i gave two ng-app like <body> <div ng-app="A"> <div ng-controller="AC"> </div> </div> <div ng-app="B"> <div ng-controller="BC"> </div> </div> </body> Then second ng-app does not work. But when i change the scope of first ng-app="A" from div to body then both works fine like <body ng-app="A"> <div> <div ng-controller="AC"> </div> </div> <div ng-app="B"> <div ng-controller="BC"> </div> </div> </body> Can anyone let me know why this behavior as

How to trigger a scope function defined inside a Directive

99封情书 提交于 2019-12-12 09:58:33
问题 I'm using a Dashboard framework in my Angular application which has lots of directives. Within the main directive there are some scope functions which are getting called from an html template using ng-click, for example, when a user adds a widget to the dashboard via a dropdown menu : <div class="btn-group" ng-if="options.widgetButtons"> <button ng-repeat="widget in widgetDefs" ng-click="addWidgetInternal($event, widget);" type="button" class="btn btn-primary"> {{widget.name}} </button> </div

AngularJS Failed to load template

≡放荡痞女 提交于 2019-12-12 09:56:34
问题 I am trying with AngularJS directive, here is my code: index.html <!DOCTYPE html> <html lang="en" ng-app="myapp"> <head> <meta charset="UTF-8"> <title>Directive</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.js"></script> <script type="text/javascript" src="app.js"></script> </head> <body> <photo photo-src="abc.jpg" caption="This is so Cool" /> </body> </html> app.js var app = angular.module('myapp',[]); app.directive('photo',function