Questions tagged [angularjs-compile]

Compiles an HTML string or DOM into a template and produces a template function, which can then be used to link scope and the template together.

Compiles an HTML string or DOM into a template and produces a template function, which can then be used to link scope and the template together.

The compilation is a process of walking the DOM tree and matching DOM elements to directives.

Reference:
$compile

145 questions
4
votes
2 answers

Getting a $rootScope:inprog error, but it requires scope.$apply to work

Is there a way of applying scope in the snippet below without it throwing an error? (and without hacks and workaround like try/catch, $timeout or hard-coding BONJOUR) Without SCOPE.$apply(), the alert shows {{HELLO}} instead of BONJOUR. var app =…
Blaise
  • 13,139
  • 9
  • 69
  • 97
3
votes
2 answers

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/$compile
RJV
  • 287
  • 1
  • 7
  • 20
3
votes
1 answer

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($compile) { return { scope: { …
Vincent Wasteels
  • 1,568
  • 2
  • 14
  • 21
3
votes
2 answers

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, questiontext: 'Type', questiontype: 1 ,…
3
votes
1 answer

Use angular compileProvider outside config block

I'm trying to create directives on the fly, actually I achived that, but seams pretty hacky. This was my first approach: function create(myDir) { angular.module("app").directive(myDir.name, function() { return { template:myDir.template …
3
votes
1 answer

Compiled directive with isolate scope variable coming up undefined

I need to compile a directive because it needs an ID that comes back from the DB, but can't seem to get that to persist through to the directive. $scope.orderInfo = { orderId: 'lkdfj232jh' }; $scope.compile = function() { var html =…
2
votes
0 answers

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 knows why? See the code below. The "Hello World" is…
TDT
  • 514
  • 5
  • 7
2
votes
1 answer

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 function of the $chatWidget service: var build =…
2
votes
2 answers

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
with the appropriate based on a variable type…
oodavid
  • 2,148
  • 2
  • 23
  • 26
2
votes
1 answer

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(scope, element, attrs) { scope.$watch( …
2
votes
0 answers

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.
{{tittle}}
Ajith
  • 343
  • 2
  • 23
2
votes
3 answers

I am getting error Error: [$compile:tplrt] while using directive in angularjs

In angularJS 1.3.14 var app = angular.module('myApp',[]); app.controller('myController',['$scope',function($scope){ $scope.name = 'world'; }]); //here i created directive of name helloWorld app.directive('helloWorld',function(){ …
2
votes
2 answers

How to get the original attribute name before it was normalized/denormalize an attribute name?

I want to create a directive that I can use on with a globally known list that's dynamically updated and shared among all the components in the app. I envision using it like so:
Claudiu
  • 224,032
  • 165
  • 485
  • 680
2
votes
0 answers

Extending Scope function to Directive in Angular 1.4

I am trying to extend the angular-ui.github.io/bootstrap/ datepicker and it seems not to work. angular.module('myApp', [ 'ui.bootstrap' ]) .config(function($provide) { $provide.decorator('datepickerDirective', function ($delegate) { …
2
votes
1 answer

ng-click fired multiple times after compile

I have read many SO answer but couldn't resolve the problem. I have a Javascript function that create HTML element like document.createElement(...) This is a part of that function : var…
Merlin
  • 4,907
  • 2
  • 33
  • 51
1
2
3
9 10