i have angularjs stuff holds bunch of arrays , data. once user uploads file, file gets parsed , saved scope different arrays. however, after of , file held in scope, try update innerhtml, angularjs code not work. use ng-repeat
create table based on arrays, remains single cell content looking {{column}}
, like.
i have had extreme difficulty using directives , templates because index.html says app
, module
, etc, undefined when such app.directive(...
the significant parts of index.html file include:
<html ng-app> ... //once file uploaded, total.js called; //this app didn't try run before file uploaded <div id="somestuff">this become table once file uploaded</div>
this simple example of how scope set in total.js:
function sheet($rootscope, $parse){ $rootscope.stuff = text; //text variable contains file's contents string }; document.getelementbyid('somestuff').innerhtml="<div ng-controller='sheet'>{{stuff}}</div>";
the html changes instead of printing file's contents, prints {{stuff}}
. how can innerhtml understand contains angularjs, preferably without using partial or directive, unless can thoroughly explain i'd input , syntax of it.
edit 1: have tried using $compile marked undefined. looked @ this figure out compile problem, don't understand rtcherry's syntax, , how should apply own code.
edit 2: still receive $compile undefined errors when include so:
function sheet($rootscope, $parse, $compile){...}; document.getelementbyid('somestuff').innerhtml=$compile("<div ng-controller='sheet'> {{stuff}}</div>")(scope);
edit 3: while itcouldevenbeaboat's comment extremely unhelpful, decided should perhaps show directive way attempted it.
i included code under sheet function:
var app = angular.module('app', []); app.directive('spreadsheeet', function($compile){ return{ templateurl: innerhtml.html } });
where innerhtml contains <div ng-controller='sheet'>{{stuff}}</div>
and on index.html i've included <div spreadsheet></div>
with this, receive no errors, text not show up, neither {{stuff}}
or file's contents. when simple, such provide template: "<h2>hello!</h2>"
instead of templateurl
, cannot hello!
print.
it works me
document.getelementbyid('somestuff').innerhtml = "<div ng-controller='sheet'>{{stuff}}</div>"; $compile( document.getelementbyid('somestuff') )($scope);
Comments
Post a Comment