angularjs - Trying to get an element from a template -



angularjs - Trying to get an element from a template -

i trying element template in different ways, none of them seems work. code:

<!-- language: lang-html --> <div ng-controller="mainctrl"> <div id="main-content"> <h1>main content</h1> </div> </div> <!-- language: lang-js --> angular.module("mainmodule", []) .controller("mainctrl", ["$scope", "$document", function ($scope, $document) { $scope.init = function() { var element = angular.element("#main-content"); console.log(element); element = angular.element("main-content"); console.log(element); element = $document.find("#main-content"); console.log(element); }(); }]);

maybe 1 of got idea? help!

you should create directive that. angularjs controller should never reference dom elements.

angularjs

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -