angularjs-directive

Controller <directiveName>, Required by Directive 'ngClass', Can't be Found

偶尔善良 提交于 2019-12-11 06:45:06
问题 I get the error "Controller 'gssResponseGroup', required by directive 'ngClass', can't be found!" when using the linked Plunker files. Problem is, sometimes it works perfectly fine and other times I get this error. My guess is that the order of loading/compiling of the directives is not consistent. Anyone have any ideas? Plunker I don't see why it states that it can't be found. It is defined right above in the same JavaScript file. 回答1: I can't recreate your error, but I am guessing the

Put an index to a model with ng-options for a simple array

佐手、 提交于 2019-12-11 06:21:33
问题 For the following code (see fiddle): HTML: <div ng-app ng-controller="MyCtrl"> <select ng-model="ampm" ng-options="currOption for currOption in ['AM', 'PM']"></select> AM/PM: {{ampm}} </div> JS: function MyCtrl($scope) { $scope.ampm = "AM"; } The result is, HTML: <select ng-model="ampm" ng-options="currOption for currOption in ['AM', 'PM']" class="ng-pristine ng-valid"> <option value="0" selected="selected">AM</option> <option value="1">PM</option> </select> ... which is perfectly fine.

ng-repeat doesn't work when HTML is altered under $compile

感情迁移 提交于 2019-12-11 06:18:12
问题 Directive code: .directive('replace', function($compile) { return function (scope, element) { element.html(element.html().replace("Hej", "Hey!")); $compile(element.contents())(scope); } }); }) HTML <div ng-controller="GreeterController"> <div replace>Hej <div ng-repeat="e in arr">{{ e }}</div> </div> </div> Controller app.controller('GreeterController', ['$scope', function($scope) { $scope.arr = [1, 2, 3, 4]; }]); Live example As the title says, ng-repeat doesn't work when I'm using the

Advanced manipulating DOM in AngularJS directive

若如初见. 提交于 2019-12-11 06:16:12
问题 I'm resolving rights in AngularJS application... I would like to use custom directive for resolving what user can see by his role. It's only client side design. If user entry on page what he hasn't access, server return 403 for all requests for data from this page. My actual solution looks like this: <li ng-repeat="menuItem in navigationItems" class='{{menuItem.css}}' restrict-access="menuItem.restrict"> <a href="#/{{menuItem.url}}"> <div class="label"> <span class="icon"> <span class="title"

Unexpected token < - Evaluating /lib/angular2-modal/plugins/bootstrap.js - missing file bootstrap.js in lib folder

主宰稳场 提交于 2019-12-11 05:59:43
问题 I am facing some issues in loading angular2-modal popup. Getting this exception "Unexpected token < - missing file lib/angular2-modal/plugins/bootstrap.js" After compiling when I try to launch the application, it is trying to evaluate the file in the path " Evaluating http://localhost:49928/lib/angular2-modal/plugins/bootstrap.js " But in the specified location no such file exists and hence the application is getting crashed. Under the lib/angular2-modal/plugins/ folder, bootstrap.js file

Angularjs form with and without refresh

对着背影说爱祢 提交于 2019-12-11 05:48:13
问题 I would like to use an Angularjs form directive in the following way: if it's in /home redirect to /search/term and if already in /search process the submit without page refresh just changing the location. I know how to do both, but I don't know how to write a reusable code which works in both examples. 回答1: You won't be able to submit form data without a page refresh, unless you submit the data asynchronously via XHR. It sounds like you are submitting synchronously via HTTP POST or GET at

Angular directive 1 way binding is working but 2 way binding is not

血红的双手。 提交于 2019-12-11 05:44:57
问题 I am not using scope in my controller as i use controller as etc.. I have proof of concept that plunker without scope is working 1 way binding is working 2 way binding is NOT working - shows literal value HTML page WORKING Here: {{detail.program.ldcCode}} SHOWS "Here: PNLC" <lcd-code code="{{detail.program.ldcCode}}"></lcd-code> Above passes in 1 way binding of that object/value of PNLC to Directive ! Directive : return { replace: true, restrict: "EA", scope: { code: "@" }, link: function

angularjs : setting class attribute in a directive template

余生长醉 提交于 2019-12-11 05:30:32
问题 I'm trying to set the class attribute of my directive. That's how I do it: the relevant code in the directive template: '<input class="myClass" />' scope:{ myClass = '@' } and that's how I call it <my-directive my-class="someClass" /> Unfortunately, nothing happens. No errors, but the class is just not set. Anything I'm missing ? 回答1: myClass is a scope variable in your new isolated scope. You have to write template: '<input class="{{myClass}}" /> or template: '<input ng-class="myClass" /> 来源

Passing Information to Directive to Match Passwords

房东的猫 提交于 2019-12-11 05:27:16
问题 I'm trying to add an errors to my floating placeholder labels when certain conditions are met in my controller However, I'm not sure the best way to go about this and my current implementing doesn't seem to be detecting the attribute change in the directive (custom-error stays set to "test"). Here's what I've got right now: HTML: <input type="password" float-placeholder custom-error="test" placeholder="Confirm password" required name="passwordSecond" id="passwordSecond" ng-model="vs

How do I include other directives in the template of my customer directive in Angular?

孤者浪人 提交于 2019-12-11 05:05:51
问题 I wrote a simple custom directive. The template in this directive includes other directives (e.g. ui-sortable ). Because it doesn't always use ui-sortable, I add it in the link phase. Yet it doesn't seem to apply: link: function ($scope,$element,attrs) { attrs.$observe('admin', function(value) { if ($scope.admin) { $element.find("span").html("true"); $element.find("ul").attr("ui:sortable","sortableOptions"); } }); } Full fiddle example is here: http://jsfiddle.net/VjfEf/4/ There are two lists