angularjs-directive

Directive doesn't work when I which the version of Angular to 1.0.1 to 1.2.27

为君一笑 提交于 2019-12-13 05:43:28
问题 The following could be run in demo here. this is html: <div ng-controller="MyCtrl"> <h2>Parent Scope</h2> <input ng-model="foo"> <i>// Update to see how parent scope interacts with component scope</i> <br><br> <!-- attribute-foo binds to a DOM attribute which is always a string. That is why we are wrapping it in curly braces so that it can be interpolated. --> <my-component attribute-foo="{{foo}}" binding-foo="foo" isolated-expression-foo="updateFoo(newFoo)" > <h2>Attribute</h2> <div> <strong

How do I create a dynamic nav which gets allowed menu items passed to it?

落花浮王杯 提交于 2019-12-13 05:39:27
问题 For building the actual navigation, I like this approach: http://jsfiddle.net/xUsCc/1/, which I found here: Recursion in Angular directives, also created a follow up question here: how do i bind a directive to an injected service instead of a parent or isolated scope? The problem is that the directive gets its data from an attribute on the markup, which is a scope variable on the parent scope, like so: <tree family="treeFamily"></tree> The navigation bar sits outside the view, so there is no

Directive not working in IE8

天大地大妈咪最大 提交于 2019-12-13 05:36:57
问题 I have a directive called barsMax and it is not working in IE8, even if I already placed: <!--[if lte IE 8]> <script> document.createElement('bars-max'); </script> <![endif]--> What am I missing? 回答1: Code you are using also has a pseudo tag bars-current . Adding document.createElement('bars-current'); to your polyfill worked for me. DISCLAMER : Am Using IE10 in IE8 standards mode but error thrown in console if don't create elements first and jsfiddle itself falls apart without it in IE8 DEMO

Scope doesn't get associated with new element added in compile phase

我是研究僧i 提交于 2019-12-13 05:33:23
问题 In below code i am trying to add a button at compile phase, and assigned ng-click to a method from scope. During linking phase, through debugging I found the "compiledEle" contains the button, then also ng-click doesn't call the scope method. angular.module("app", []) .controller("ctrl1", function($scope){ $scope.myModelObj = { name: 'Ratnesh', value: 100 }; }) .directive("dirOne",function($compile){ return { restrict: 'E', scope: { myModel : "=" }, compile: function(ele){ ele.append("<button

how to make tab bar in angular js with sliding effect?

烂漫一生 提交于 2019-12-13 05:30:12
问题 how to make tab bar or navigation bar in angular with sliding effect .I am able to make in jQuery mobile .Here is my fiddle http://jsfiddle.net/ezanker/o9foej5L/1/ When I used same thing in angular it not work I need to do same thing in angular js .can you please tell me how we can achieve this in angular js Plunker: http://plnkr.co/edit/ornYCV15uV8lPNL1ujPL?p=preview <html> <head> <link data-require="bootstrap-css@3.x" data-semver="3.2.0" rel="stylesheet" href="http://maxcdn.bootstrapcdn.com

Angular controller in directive cause strict di error

吃可爱长大的小学妹 提交于 2019-12-13 05:19:18
问题 I use the ng-strict-di mod in my app. It works for all my DI, except when I try to use a controller in a directive. FYI I use the John Papa style guide to format my code. Here is my directive : (function () { 'use strict'; angular .module('app.mymodule') .directive('myDirective', myDirective); myDirective.$inject = []; function myDirective() { var directive = { bindToController: true, controller: MyDirectiveCtrl, controllerAs: 'vm', restrict: 'E', scope: { data:'=' }, templateUrl: 'my

Angular compile template error on local project and jsFiddle, but working fine in Plunker

只愿长相守 提交于 2019-12-13 05:17:52
问题 I've noticed my angular controller is growing and have been trying to refactor and use directives and services. However, on one scenario, i am trying to create a directive which appears to be working fine in plunker, however i am seeing the following error in my local application and in jsFiddle: Error: [$compile:tplrt] http://errors.angularjs.org/1.2.8/$compile/tplrt?p0=getEmptyCells&p1= Plunker link: http://plnkr.co/edit/e11zA8LKvoPTgTqW2HEE?p=preview jsFiddle link (error can be seen in

How can I update a directive when a service finishes loading in a controller in AngularJS

北城以北 提交于 2019-12-13 05:17:28
问题 In an AngularJS app, I have a service that uses $http and returns a promise. I have a controller which requires the service. In the controller DataService.then(function(data){ scope.viewModel.data = data;}) Then I have a directive with isolate scope. scope: { data: '='} then do something with scope.data inside the directive. Finally the html <div ng-controller="myCtrl"> <div my-cool-directive="" data="viewModel.data"></div> </div> My question is this presents a chicken before the egg scenario

how to make filters with $scope variables inside controllers of directives

核能气质少年 提交于 2019-12-13 05:16:40
问题 I have found lot of conventions to write code in angular JS. I am using the following convention. app.directive("employeeList" , function(){ return { restrict : 'E' , templateUrl: 'employee-list.html', controller:function($scope , $filter) { $scope.emp_positions = positions_json; // my FIREST array $scope.emp_users_json = users_json; // My SECOND Array //My Code Logic // // I WANT TO MAKE FILTER HERE WHICH CAN USE $SCOPE VARIABLE. IS THERE ANY WAY TO MAKE FILTER HERE LIKE $SCOPE.FILTER(

how do i bind a directive to an injected service instead of a parent or isolated scope?

浪子不回头ぞ 提交于 2019-12-13 05:15:07
问题 related to this question: How do I create a dynamic nav which gets allowed menu items passed to it? Basically, I have a nav outside of any views. The nav needs to display menu items which a user has access to. I create the nav markup with a directive like so: <tree family="treeFamily"></tree> Where treeFamily is the data which will be used to build the navigation menu. However, since my nav is outside of any views, it doesn't have a controller, so there is no scope variable called treeFamily