angularjs-directive

angular ng-show / ng-hide not working correctly with ng-bind-html

我们两清 提交于 2019-12-10 18:05:23
问题 I want to set ng-show or ng-hide for my elements in html string and pass it to view with ng-bind-html but ng-show / ng-hide not working and my element always visible. This is my controller code: $scope.my = { messageTrue: true, messageFalse: false }; $scope.HtmlContent = "<div ng-show='{{my.messageFalse}}'>This is incorrect (ng-show & my.messageFalse={{my.messageFalse}})</div> "; $scope.trustedHtml = $interpolate($scope.HtmlContent)($scope); And this is my view code: <div ng-show="my

Is it bad practice for an angular directive to request data

怎甘沉沦 提交于 2019-12-10 17:53:44
问题 Consider for example a currentUser directive. I could let the controller use a service to get the data about the current user, provider it to the directive and let the directive render some "hello {user.name}" template. Alternatively I could have the directive have a dependency on some currentUserService and in the directive's controller ask for currentUserService.getCurrentUser. Is one of the two significantly better then the other for any reason? I tend to go with the first option but not

Angularjs routing: TypeError: Cannot read property 'path' of undefined

 ̄綄美尐妖づ 提交于 2019-12-10 17:52:00
问题 I'm new to AngularJS. Can someone help me why the following routing will not work? I have a custom directive that submits a user form. After submission, it should navigate to the success page.(views/success.html). I'm getting an error upon submission. TypeError: Cannot read property 'path' of undefined If I simply try navigate to "/index.html#/success" on the address bar, it will not redirect to the success page, so I'm suspecting it is a routing issue but I can't seem to understand the cause

Angular directive for bootstrap popover

随声附和 提交于 2019-12-10 17:43:30
问题 I write my custom directive for bootstrap popover, but face some trouble. This is the code: angular.module('CommandCenterApp') .directive('bzPopover', function($compile,$http, $commandHelper) { return{ restrict: "A", replace: false, scope: { currencies:"=data", selected:"=selected" }, link: function (scope, element, attrs) { var html = '<div class="currency-popup">' + '<span class="select-label">Select currency:</span>'+ '<select class="custom-select" ng-model="selected" ng-options="currency

directive can not ''require:ngRepeat'

こ雲淡風輕ζ 提交于 2019-12-10 17:38:10
问题 I write below directive to make call a function when ngRepeat element gets rendered on UI. Directive directives.directive('repeatDone', function() { return { restrict: 'A', require: 'ngRepeat', link: function(scope, element, attrs, ngModel) { if (scope.$last) { scope.$eval(attrs.repeatDone); } } }; }); But it is giving $compile error. If I remove require part, it works OK. Why AngularJS can not accept "require: 'ngRepeat'"? Help would appreciated. 回答1: require is used for accessing the

Pass data from one directive to another

不想你离开。 提交于 2019-12-10 17:34:41
问题 I have a directive that uses custom template, and I would like to pass the data from that directive to another one, and looking for the best possible way. So, I would like when the data inside the directive one changes, directive two get notified(watcher?), and acts upon it. So far, only the method with controller inside the directive one, and a watcher inside directive two for the controller method(from directive one) makes sense. Is there a a better way for this ? -------------- -----------

How to call directive from template html in angularjs

老子叫甜甜 提交于 2019-12-10 17:34:09
问题 Html <script type="text/ng-template" id="ProfileTemplateHTML" > <div class="container profilepopup-cont" align="center"> <div class="row"> <div class="col-sm-3 zero-margin-padding" align="center"> <img id="DisplayImage" ng-src={{model.picLarge}} class="img-circle"> </div> ... </script> In this html template file i have to call a directive.My directive name is 'help'.But if i add to call the directive it is not working. how to call a directive inside html template in angularjs? 回答1: You can

AngularJS scope values undefined in link

∥☆過路亽.° 提交于 2019-12-10 17:04:51
问题 I'm trying to figure out something with scope and link when a directive is initialized. I have a directive in a tree controller to display details at a branch point: <typelists sub="branch.subBranches[0]"></typelists> The (relevant parts of the) directive that handles that branch info are below: listsApp.directive( 'typelists', function($rootScope) { return { restrict: 'EA', replace: true, scope: { branch : '=sub' }, templateUrl: templateDir + '/typelists.html', link: function (scope, element

AngularJS directive is breaking based on first character of directive name

故事扮演 提交于 2019-12-10 16:56:07
问题 I wrote an Angular directive that is exhibiting some strange behavior. The directive adds a function to $parsers to limit what the user types based on a regex pattern. If the current text doesn't match the patter, the parser reverts the text back to the previous value of the field. As a result, when the text is reverted, Angular detects this as a change in the field value and enters the parser again. This is normally fine since the value passed into the parser is now valid but I am

AngularJS formatted number calculation

别说谁变了你拦得住时间么 提交于 2019-12-10 16:46:12
问题 Yesterday, I am having trouble on how to make a formatted number in my number fields but now that I achieve it, I am having problem on how to do the calculation. index.html <div ng-controller="MyCtrl"> <input ng-model="var.value" class="integers" symbol="°" /> <br /><br /> {{var.value * 100}} </div> app.js var myApp = angular.module('myApp',['ui.numeric']); angular.module('ui.numeric', []).directive('integers', function() { return { require: 'ngModel', restrict: 'EACM', link: function(scope,