Tagged Questions
0
votes
1answer
27 views
Update directive variable from controller
New to AngularJS I have a simple directive, service and controller. I loop through a list of items from a database in the controller embedded in the directive to render a checkbox list of items. From ...
0
votes
1answer
53 views
Sharing a controller scope between two directives with isolate scopes in AngularJS
I have two directives that provide different views on the same set of data. Both of these directives need to rely on central functionality contained in a controller. The controller uses various ...
1
vote
1answer
37 views
AngularJS directive using another controller
I'm trying to create a directive that will output a HTML-template that is using data from a controller.
In sample.js I've added a module, controller and directive
var app = angular.module("myApp", ...
0
votes
1answer
37 views
Where to put in logic for manually adding and removing classes for an anchor tag - Angular JS
I have a main html page in which I have an anchor tag (looks like a button explained below), a drop down with some values and a check box. Code is given below.
I have an anchor tag that makes it ...
0
votes
2answers
45 views
AngularJs Directives Loaded Event
I have just started using AngularJs directives, using the resources here, here and here.
I have a situation where i need to do something after all directives have been loaded.
i.e
Scenario 1
...
0
votes
1answer
27 views
angularjs app design multiple instances of the same component (directive or directive+controller)
My app needs to have multiple instances of a component that manages a complex model.
to display the model and the UI/DOM logic including a template with child directives I'v created a directive,
the ...
0
votes
2answers
35 views
Send Object From Directive to Parent Controller in AngularJS
How can I send an object back from a directive into the parent controller?
I've defined the following directive:
app.directive('inspectorSharedObjects', function () {
return {
restrict: 'E',
...
0
votes
1answer
48 views
Unknown provider: bProvider <- b
I have an AngularJS project with Directives and Controllers. After a while i got this error when I tried to run it:
Error: [$injector:unpr] Unknown provider: bProvider <- b
I have googled it and ...
0
votes
1answer
46 views
Call controller method from directive
I have a button which change the "active" state. First, it loads the status from the server
<button active="data.active" ng-click="changeStatus()"></button>
directive code:
...
0
votes
2answers
24 views
AngularJS accessing an attribute in a directive from a controller
I need to pass an Id defined in the directive to the associated controller such that it can be used in a HTTP Get to retrieve some data.
The code works correctly in its current state however when ...
2
votes
1answer
79 views
How do I assign an attribute to ng-controller in a directive's template in AngularJS?
I have a custom attribute directive (i.e., restrict: "A") and I want to pass two expressions (using {{...}}) into the directive as attributes. I want to pass these attributes into the directive's ...
0
votes
1answer
28 views
AngularJS Directive or Service?
My current understanding of AngularJS tells me that Directives should only contain DOM Manipulation and Services everything which has to do with logic and data handling.
In my case I'm unsure which ...
0
votes
1answer
14 views
Angularjs Error: registerService.getRegisterResponse is not a function
Error: registerService.getRegisterResponse is not a function
I getting Above Error on console of the web browser. While Accessing the a method(i.e saveRegisterResponse()) from Controller (i.e ...
1
vote
2answers
79 views
ng-repeat inserting empty anchor tags
I'm trying to create a menu using angular. A menu item can have children requiring another ng-repeat to print the sub nav items. I'm noticing some strange behavior when attempting to insert an anchor ...
0
votes
1answer
46 views
AngularJS: Directive to Controller communication with scope.apply not working
I have a MainController and a nested Directive. I'm looking at this example to see how the communication works between controllers and directive, but mine doesn't seems to work.
Basically, I want to ...
0
votes
1answer
102 views
How to pass $scope data between two partial files in angularjs
How can I pass data in two partial html files using angularJS, totally weird cant get through it.
I have one index file [fine.], I login and reach view5 [partials/blog.html] which is written in ...
0
votes
2answers
29 views
how to fire a controller method from another controller or directive?
What I need is to show some values automatically when I process some data on another controller, but how can I fire my $scope.setOnController1 function on controller1 when the controller2 have ended ...
0
votes
0answers
100 views
Angularjs initialize multiple controllers at startup?
i have a normal navbar with a menuController, this is the parent.
then i have two other controllers a DashBoardController this is loaded on startup and a LoadDataController this is called if i click ...
0
votes
1answer
58 views
How to override a controller function in an angular.js plugin
While developing my first Angular.js project I ran into troble. After a day-long research I have no idea how to override a plugin controller method.
I am using a pretty nice ...
0
votes
1answer
36 views
How do I create a directive with a controller in a way where the scope will work without having to use $parent in the view?
I need to include a controller as an attribute of my-modal. In my example, showModal is not in scope unless I use $parent.showModal = false. I can't use $parent in the view for the sake of other ...
-1
votes
1answer
33 views
Angularjs HTML compilation in Controller
I am facing a small problem during the compilation of html code in angularjs. Here is the brief description of my problem :
$scope.report= reportdata;
reportdata is the html code that contains ...
1
vote
1answer
40 views
AngularJS Directive to Controller communication with “Controller as …” syntax
I'm using the "Controller as" syntax and am in a situation where I'd like the Directive to communicate with the Controller.
I can get this to work when I do NOT use the "Controller as" syntax. ...
1
vote
1answer
25 views
AngularJS - How to get directive-controller in directive with “require”
I have a directive with a require. Now I want to get the required controller instance AND the controller of the directive in the link function. How is that possible? If i set 'require' the fourth ...
0
votes
1answer
81 views
Getting data from a Controller/Service into a Directive?
I'm a relative beginner with AngularJS and am writing an app that will have various reusable components (e.g. the same table may appear 5 times on the screen, with slightly different columns - I can ...
0
votes
2answers
64 views
angularjs directive controller $element
i see angularjs highly suggested not to do any dom manipulation in the controller,
only setting the state of the scope, example pulling data from ajax etc,
https://docs.angularjs.org/guide/controller
...
0
votes
2answers
75 views
Directive talks to controller but cannot call functions residing in controller
I have a directive which needs to call functions from the Main controller but everytime i try to reference a function inside the directive nothing happens because it's undefined. When I access a value ...
1
vote
1answer
16 views
How to append a directive to another directive which calls a function from controller.
I'm trying to append a directive which occurs when an event is fired via the $watch function in angular. The first directive updater would insert a custom element <confirmation /> into my view. ...
0
votes
1answer
61 views
Initiating directive from controller
I'm having trouble figuring out a way to initiate a directive once the data has been returned. I'm trying to build a report using html tables and ng-repeat. The report object is generated using a ...
0
votes
1answer
44 views
Angular directive - when to prefer using a controller inside a directive?
I've been seing a lot of directive containing a controller in it. What are the pro / cons /differences and use cases compared to put the same code in the link function of the directive ?
One ...
1
vote
2answers
70 views
In an AngularJs directive, how do I call its controller's function contained within an directive element's attribute?
I am trying to call a function in a controller, which is part of a custom angular directive, following is the code,
Method 1: (Doesn't work: Controller's function doesn't write to the console)
HTML:
...
1
vote
2answers
125 views
How to pass async data from directive to controller?
I want to compile a third-party api (uploadcare) to a directive.
The api will return the data info after uploaded in async then I want to do something with the return data in my controller but I have ...
0
votes
1answer
358 views
changing model objects inside controllers to manipulate DOM - angular js- Best practices?
I hava a simple question after reading the post below and working for some time now on angular js.
the post : no dom manipulation from angular js controllers
the concerned point (from the post) : ...
0
votes
2answers
183 views
Passing a callback form directive to controller function in AngularJS
I have a directive and a controller. The directive defines a function in its isolate scope. It also references a function in the controller. That function takes a callback. However, when I call it ...
2
votes
0answers
121 views
Angular directive in ng-repeat doesn't call link
I'm fairly new to Angular and am having some trouble getting a directive to render within an ng-repeat. This is probably a lack of experience on my part so any help is greatly appreciated.
Here are ...
0
votes
2answers
179 views
angularJS scope not updated for function attribute inside promise block
controller('SomeController', function($scope, simpleFactory, $routeParams) {
init();
function init() {
var myDataPromise = simpleFactory.getStuff($routeParams.id);
// The ...
1
vote
2answers
321 views
AngularJS & Typescript: How to assign a class/type as a directive's controller?
AngularJS directives specify a controller using:
{
controller: function ($scope){}
}
As of yet, I have not found a way where I can create a TypeScript class and assign it to a directive's ...
0
votes
0answers
32 views
detect which directive calling a method in the controller
is there any way to detect which directive calling a function in the controller without passing any arguments from the directive itself.
simple example to demonstrate what i need:
controller:
...
0
votes
1answer
38 views
Angularjs app logic structure help required
I've recently started with Angular and would really appreciate some help on how to properly structure my code the angular way. This is more of a meta question rather then technical question.
I have ...
2
votes
1answer
107 views
How to dynamically load controller to a directive
So I have a directive that Will be acting as a side panel in my app. When a user clicks a button the side panel will open. In said side panel I need the controller and view for this area to be ...
0
votes
0answers
453 views
angular directive for tables: bind transcluded elements with ng-bind-html
I'm trying to write a generic table directive like this:
<h-table rows="customers">
<h-column field="Id">
<a ng-click="editCustomer(row.Id)">{{row.Id}}</a>
...
0
votes
1answer
24 views
Change ng-model through directive
I'am trying to change ng-model of input inside directive by clicking on Edit anchor in directives template.
Function f() is suppose to access outer controller and bind the editableValue to name or ...
0
votes
2answers
99 views
AngularJS: How to inject service into directive
I’m failing on injecting a service into a directive – it works with my controller though. According to the doc, it should be pretty straight forward.
Service:
priceGraphServices = ...
2
votes
1answer
54 views
Directives & Controllers: resolve, loading, reloading [closed]
I need a code for the next problem. I know which components ($http, $q, etc.) I have to use. I don't know how to do it in a right way! So,
I need an AngularJS directive or controller,
It loads some ...
0
votes
1answer
70 views
angularjs directive comunication
I am new to angularjs, and i have been reading a ton of documentation and reading through various articles and tutorials as well as videos to help me figure this stuff out.
i am trying to get two ...
1
vote
1answer
142 views
How can I get controller scope reliably in directive?
Let's say I have a directive that simply print out its scope id
.directive('myCustomer', function() {
return {
template: 'directive scope {{$id}}',
link: function(scope, el, attrs) {
...
0
votes
1answer
68 views
How do I access the controller I declared for an angularjs directive in the templateUrl?
I would like to use a directive with a controller but I would like to access the same controller in the url template. How can I do this? For example, I would like something along the lines of:
...
0
votes
0answers
49 views
ng-if / manually binding controller causes DOM Node count increase
I'm writing a directive to bind a template with a controller dynamically.
During this, I found that the DOM Node count kept increasing, (and the heap size too).
I'm wondering what is wrong with the ...
0
votes
1answer
19 views
In angular, how do you provide a controller's argument list from within a directive definition?
I'm trying to follow the best practice of providing an argument list when defining a controller, like this:
angular.module("myApp", [])
.controller("myCtrl", ["$scope", function ($scope) {
// ...
0
votes
4answers
66 views
Angular Directives: Link to Controller without Services
I'm gradually getting the hang of Angular directives and so far, have resorted to creating a service as an intermediary between controllers.
I was just wondering, in the context of directives (and ...
2
votes
2answers
148 views
Did I share state correctly outside angular directive? (parent scope / $rootScope issue)
I have two elements on my page which are not nested in some way. With attributes on the first one, I would like to set the content of the second one, like so:
<body>
<input info="This is ...