ng-include directive and ng-controller option with variable -
I have a question about using ng-in and ng-controllers. NG-Inclusive and NG-Controller are the same elements in the same element, I take the URL to amend.
HTML Part:
& lt; Div ng-app = "app" & gt; & Lt; Div ng-controller = "Ctrl" & gt; & Lt; Ng-model select = "template" ng-option = "t. name for t in template" & gt; & Lt; Option value = "" & gt; (Empty) & lt; / Options & gt; & Lt; / Select & gt; Template URL: & lt; Tt & gt; {{Template.url}} & lt; / Tt & gt; & Lt; Hours / & gt; & Lt; Div class = "slide-animate-container" & gt; & Lt; Div class = "slide-animate" ng-included = "template.url" ng-controller = "template.ct" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - template1.html - & gt; & Lt; Script type = "text / ng-template" id = "template1.html" & gt; The content of template 1.html {{boy}} & lt; / Script & gt; & Lt ;! - template2.html - & gt; & Lt; Script type = "text / ng-template" id = "template2.html" & gt; Template 2.html {{Girl}} & lt; / Script & gt; Content of & Lt; / Div & gt; JavaScript part:
angular Module ('app', ['ngenet']); Function Ctrl ($ scope) {$ scope.templates = [{name: 'template1.html', url: 'template1.html', ct: c1}, {name: 'template2.html', url: 'template2.html ', CT: C2}]; $ Scope.template = $ scope.templates [0]; } Function c1 ($ scope) {$ scope.boy = "Batman"; } Function C2 ($ scope) {$ scope.girl = "catgirl"; } But I switch from template1 and template 2, template2 does not show me {{girl}} value properly, why do anyone know?
Thanks Eric Exin
You can use ng-switches and instructions such as
However, the animation needs to be converted to work for the NG-switch
I like the instructions for adding ng.
Comments
Post a Comment