144 questions
0
votes
2
answers
165
views
Javascript compiler error in Chrome's console
I was doing some javascript coding in chrome's console.
When I do:
console.log(x);
let x;
It gives "ReferenceError: x is not defined"
But when I run the below code:
let x;
console.log(x);
...
1
vote
1
answer
255
views
Wait for the response from another component in angular js
I have a created a component called popupmessage to show custom message with "ok" and "cancel" button. This i am invoking from another component say component "a" using $compile like below.
a.js has ...
0
votes
1
answer
167
views
ng-if does not work when placed outside of controller and $compile-ed with scope, but ng-show does
I have a plain angular application which adds variables to the scope and simply display them. Which is simple and working.
But there is a part of the page that does not run in angular (practically it ...
-1
votes
2
answers
45
views
AngularJS directive with isolate scope
I have a directive that might look like this:
a.directive('autoResize', function($compile) {
return {
scope: {},
link: function(scope, elem) {
// HTML here is just an example
...
1
vote
1
answer
1k
views
Passing variables into ng-transclude
I am wondering, is it possible to pass an $index param into the ng-transclude? I am trying to focus into the textarea by clicking on the elements in the ng-transclude, triggering a function inside the ...
1
vote
1
answer
149
views
How to $compile with a custom compile directive
ON MYPENCODE Having the following two directives dragMe and compile :
dragMe
app.directive('dragMe',['$compile', function ($compile) {
return {
restrict: 'A',
scope:{
book:'='...
1
vote
1
answer
277
views
Getting AngularJS multilink error after upgrade from v. 1.4
I have a big directive with sub-directives where I'm getting the error. Exactly, it happens on the step when calling transcludeFn() in the link function of main directive:
var link = function ($...
1
vote
2
answers
380
views
How to use the $compile service to include HTML data with AngularJS directives
I have a controller which is populating content to content areas using ng-repeat. The issue is that some of this content needs to come front template files and so needs to be compiled 'on the fly'. ...
0
votes
2
answers
2k
views
Is "$onInit", more efficient way than "activate" to activate "controller" in angularJS? [closed]
I'm new to angularJS and want to implement the efficient thing for my project but got stuck between $onInit (life cycle hook) and activate().
2
votes
0
answers
575
views
Why AngularJS $compile does not execute javascript code?
I'm trying to compile a HTML that has style and script tags inside it. The HTML is compiled properly and the code is added to the DOM, the style also works, but the script is not executed.
Anyone ...
0
votes
1
answer
40
views
AngularJS $compile removes previous compiled-element
Background
We have an old application written i jQuery and Handlebars and we're migrating part by part to AngularJS (this work began many years ago and was never finished, hence AngularJS).
Problem
...
1
vote
1
answer
815
views
AngularJS string replacement and $compile
New to AngularJS - I am trying to create a function that finds "tokens" of specific text, replaces them with an ng-click directive bound to a function on the controller. For example, from my database ...
2
votes
1
answer
97
views
Why isn't my dynamically created element not showing up?
OK So I created a chat widget that isn't hardcoded instead it it is created by a service for example:
$chatWidget.setParent(parent).setUser(user).setMessages(messages).build();
Here is the build ...
1
vote
1
answer
378
views
Failed to load template in angular $mdDailog
I am using $mdDailog in my angularjs application.I have addUser() function which is called on ng-click operation. Inside addUser() am using $mdDailog.show(). Where I am passing html file path in ...
0
votes
1
answer
63
views
Angular 1 - Compile ng-if condition into string
I have this string :
this.badge = `<span class="badge">{{ notification}}</span>`
to interpret the {{ notification}} expression I do :
this.badge = this.$interpolate(this.badge)(this)
...
1
vote
0
answers
22
views
AngularUI popover template compiles only once , doesn't get triggered when I navigate to another page in my SPA
I'm working on a SPA Project.
At the header I have a menu template and under the menu I have ui-router routes.
I built a functionality with popover of Angular Bootstrap . And I am using built-...
0
votes
1
answer
192
views
Compile directive from dynamically inserted tag
I want to create a dashboard comprising of several smaller "apps". I have the following markup (simplified):
<div id="rowcontainer">
<div ng-repeat="appRow in dashboard.appRows">
&...
7
votes
1
answer
7k
views
When using $compile on component, why is the scope passed through $parent?
I'm trying to dynamically compile an Angular component using $compile, but the scope isn't passed to the components scope, but to the $parent scope instead.
Here is a simple component that binds to a ...
1
vote
3
answers
977
views
how to call angularjs function which is appended in div
$scope.showtbleoption = function(id)
{
console.log(id);
$("#showoption").empty();
$("#showoption").append('<button class="btn btn-info" ng-click="editrc(id)">');
};
how to call ...
0
votes
0
answers
65
views
what is angular js compiler linking function
I am a bit confused about the line taken from Angular JS official documentation:
Compile: traverse the DOM and collect all of the directives. The result is a linking function.
I am not clear about ...
2
votes
2
answers
462
views
Custom Directive fails to compile within ng-repeat
Could anyone help me solve a scoping issue when compiling a directive within ng-repeat?
https://plnkr.co/edit/y6gfpe01x3ya8zZ5QQpt?p=preview
The custom directive input-by-type can replace a <div&...
0
votes
1
answer
101
views
Directive under ng-if doesn't get recompiled when inserted in DOM
Here's an example which demonstrates the problem described in the title: https://plnkr.co/edit/Xn1qgYftc5YHMsrGj0sh?p=preview
Directive code:
.directive('translate', function($compile) {
return {
...
0
votes
4
answers
161
views
AngularJs Custom Directive scope data overwritten
I have displayed the products based on branch and billing account. In the product template, i have a "+" button, if we click on the button, then i'm displaying the particular product id below that ...
1
vote
0
answers
91
views
Angularjs compile html without inserting into view
I have a page that contains of widgets.
Widget is object with settings & templateUrl where I bind these settings, so I build my page compiling these settings using $compile service via directive. ...
1
vote
2
answers
135
views
Why won't $compile work with service using a directive?
Please have a look at this example, since it is the best way to explain the problem.
In this example if you click the directive link, it does not compile the template, but instead displays it as "{{...
3
votes
2
answers
21k
views
Working with $compile in angularjs
I am really confused with $compile in angularjs.
can anyone help me, What use of $compile in angularjs with an example
other then in this documentation.
https://docs.angularjs.org/api/ng/service/$...
0
votes
1
answer
624
views
How to get dynamic content with script tag working in AngularJS?
I'm trying to integrate AngularJS to existing web application. Some of data in application is loaded dynamically via $.ajax() and element.html(data). data can contain html code with javascript code in ...
0
votes
1
answer
1k
views
Angularjs - Scope value is not applied in template
I have used the directive scope in directive template.
I have tried to get the html from template cache which was stored earlier.
But the current directive scope is not applied to the directive. I ...
4
votes
3
answers
811
views
AngularJS ng-if not deleting element after $compile
I have a directive that does the following:
Adds another directive attribute to the element.
Removes its own attribute.
Calls $compile() on the element to make AngularJS re-compile the element so the ...
-1
votes
1
answer
742
views
Angular $compile for dynamic content
Using Angular 1.5, I want to use a generic "overlay" component to display other components within a modal. I'd like to pass in other components to be rendered within the overlay.
I thought I could ...
1
vote
1
answer
605
views
AngularJS detect when $compile HTML string is done
I'm using $compile to compile a directive on the fly. What I would like to know is if there is a way to detect when the directive is done compiling (promise?) so that I can append it to the DOM. I ...
2
votes
1
answer
2k
views
Unit Test angularjs directive with watch on element height
I am planning to unit test a angular directive using jasmine. My directive looks like this
angular.module('xyz.directive').directive('sizeListener', function ($scope) {
return {
link: function(...
1
vote
1
answer
271
views
How do I pass data to a component compiled through the use of $compile in AngularJS?
I would like to construct a single page app. When a user clicks on a particular object I would like to replace the current component on the page with another component. The code below is situated in a ...
1
vote
1
answer
447
views
Angular: How do I compile once then destroy all watches?
Due to performance issue, I would like to be able to simply compile a template piece once, then completely remove all watches etc from it, simply use the final template for display purpose only.
I ...
0
votes
0
answers
83
views
Error Expression in AngularJS
<div id="{{tagid}}" ng-repeat="item in arrItem">
{{addCompileTag(item)}}
</div>
</code>
In addCompileTag(item) function, I use id of the div tag is "tagid" to $compile HTML DOM ...
6
votes
1
answer
649
views
why ng-repeat changes order of link function execution
The usual order of execution of compile and link function on nested directives is as below
Markup
<dir1>
<div dir2="">
</div>
</dir1>
Order of execution
1) compile of ...
3
votes
1
answer
1k
views
Can Angular directive compile ng-click elements
I wrote a directive that will render subelements with ng-click directive on them, this is the code I have :
DIRECTIVE
angular.module('myApp')
.directive('popover', [
'$compile',
function($...
0
votes
0
answers
1k
views
TypeScript AngularJS directive for compile?
How do I implement this in AngularJS 1.5.4 with TypeScript 1.6.2?
Here is the vanilla JavaScript version from the official docs: $compile#example
I've found this, but it doesn't work: Angularjs+...
1
vote
1
answer
438
views
$watch in post link of compile not working
I am trying to apply $watch on a attribute in the post link function.
My code is like this :
compile: function(){
return {
post:function(scope,element){
scope.$watch('...
1
vote
1
answer
72
views
Dynamic Element with AngualrJS $compile
I am creating dynamic button and using $compile to bind ng-click event. I am adding two parameters there. Problem is that if the parameter is string and having space in between, Parameter is splitting....
4
votes
1
answer
1k
views
Prevent AngularJS from compiling contents of element
Is there a way to tell Angular to not compile contents of certain elements?
Use case:
Angular CMS contains textarea elements that have CKEditor attached. The CKEditor is using the divarea plugin ...
0
votes
0
answers
96
views
Add angular content in link stage of a directive
I'm trying to make a custom tooltip that contains a table populated by ng-repeat.
My directive looks like the following:
app.directive('picker', function ($compile) {
return {
restrict: 'A',...
4
votes
2
answers
981
views
Renaming 3rd party Angular Directive using $provide - not working
I've using the excellent Angular UI bootstrap in a large site alongside lots of my own directives. For the sake of neatness I looked for a way of renaming a couple of the uib directives without ...
0
votes
1
answer
682
views
Angular ng-model don't work
I'm trying to replace specific string in my text with inputs with ng-models. I used following code:
inlinetext.replace(buffer[x], '<input ng-model="singleQuestion.inlines[' + x + '].checkAnswer" ...
0
votes
1
answer
258
views
AngularJS $compile and external directive ui-codemirror
I am trying to use the external module, angular-ui-codemirror, to display the $element.html() of an enclosing AngularJS directive in a code-formatted block, using nested directive ui-codemirror.
If ...
13
votes
1
answer
20k
views
What is the best way to pass functions between inner components in AngularJS 1.5?
I was wondering what is the best way to pass functions down through 2 or more levels of components? There's no simple way of skipping the function wrap when using '&' bindings?
Here's an use ...
0
votes
2
answers
285
views
How to stop nested directive execution from an outer directive?
I'm creating a directive which will restrict HTML access if some condition are not met. Unfortunately issue arises when inner directives get called before inner HTML is changed and compiled.
Is it ...
0
votes
1
answer
595
views
I am getting issue in changing inner HTML of div
I found a problem in changing html of div:
document.getElementsByClassName("lab")[0].setAttribute("ng-bind-html", "binds");
$scope.binds="<h1>run</h1>";
I am setting attribute ng-bind-...
2
votes
0
answers
484
views
html is not compile on append new child in angular js
I am trying to insert a node dynamically, but the appended html is not getting compiled correctly.
This is the code on Fiddle.
<body ng-app="app">
<div ng-controller="appController">
...
3
votes
2
answers
625
views
Dynamically add a directive
I'm generating a report with collection of questions.
app.controller('reportCtrl', ['$scope','$stateParams', function ($scope, $stateParams) {
$scope.questions: [
{ questionkey: 1, ...