Multiple directives asking for templates on
Both of your directives are trying to replace the element in the dom. Try removing the the replace: true lines in your directive definition object.
Both of your directives are trying to replace the element in the dom. Try removing the the replace: true lines in your directive definition object.
We can achieve the same without using angular-ui. This can be done using angular directives. First add the directive to the modal. <div class=”modal fade” my-modal ….>…</div> Create a new angular directive: app.directive(‘myModal’, function() { return { restrict: ‘A’, link: function(scope, element, attr) { scope.dismiss = function() { element.modal(‘hide’); }; } } }); Now call … Read more
ng-class just sets classes on the DOM, after the compilation process. Perhaps a better way to apply the directive would be through an HTML attribute: <div test-case> Of course, this is not conditional, but I would leave the conditioning to the directive: <div ng-app=”example” ng-controller=”exampleCtrl”> <div test-case condition=”dynamicCondition”>Hello</div> <input type=”checkbox” ng-model=”dynamicCondition”/> Condition </div> and angular.module(‘example’, … Read more
It works in conjunction with ng-model; for radios and selects, it is the value that is set to the ng-model when that item is selected. Use it as an alternative to the ‘value’ attribute of the element, which will always store a string value to the associated ng-model. In the context of radio buttons, it … Read more
The best approach for you to communicate between the two controllers is to use events. Scope Documentation In this check out $on, $broadcast and $emit. In general use case the usage of angular.element(catapp).scope() was designed for use outside the angular controllers, like within jquery events. Ideally in your usage you would write an event in … Read more
Here’s how alert directive is tested in angular-ui/bootstrap. Here’s another simple set of tests, for the buttons directive. Here are a few tips: Be sure to tell the test runner what module you are testing with beforeEach(module(‘myModule’)). If you have external templateUrls in your directives, you’ll want to somehow pre-cache them for the test runner. … Read more
After release of Angular v1.5 with multi-slot transclusion it’s even simpler. For example you have used component instead of directive and don’t have access to link or compile functions. Yet you have access to $transclude service. So you can check presence of content with ‘official’ method: app.component(‘myTransclude’, { transclude: { ‘slot’: ‘?transcludeSlot’ }, controller: function … Read more
There are different ways of doing it: $setViewValue() updates the view and the model. Most cases it is enough. If you want to disconnect view from the model (e.g. model is a number but view is a string with thousands separators) then you could access directly to $viewValue and $modelValue If you also want to … Read more
From the docs on angular.element: find() – Limited to lookups by tag name So if you’re not using jQuery with Angular, but relying upon its jqlite implementation, you can’t do elm.find(‘#someid’). You do have access to children(), contents(), and data() implementations, so you can usually find a way around it.
AngularJS sets the CSS classes ng-pristine and ng-dirty on any input field you’ve used ng-model on, and your FormController has the properties $pristine and $dirty which you can check to see if the form is dirty or not. So yes, it’s possible. Could you provide some code that shows what you’re trying to do? That … Read more