angularjs - Why is this SVG's width not set with ng-attr-width? -
I have a very simple web page that I do not understand to try to isolate NG binding :
& lt; Html ng-app = "angularSVGTestApp" & gt; & Lt; Top & gt; & Lt; Title & gt; Angular SVG Test & lt; / Title & gt; & Lt; Style & gt; SVG {background color: aqua; } & Lt; / Style & gt; & Lt; / Head & gt; & Lt; Body ng-controller = "MainCtrl as main CTRL" & gt; & Lt; Div ng-cloak & gt; & Lt; Svg ng-show = "mainCtrl.svg.show" xmlns = "http://www.w3.org/2000/svg" baseprofile = "full" version = "1.1" ng-entry-width = "main CTRL Svg Width "ng-attr-height =" mainCtrl.svg.height "& gt; & Lt; / Svg & gt; & Lt; / Div & gt; & Lt; Script src = "/ script / angular.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Angular.module ('AngularSVGTestApp', []). Controller ('MainCtrl', ['$ http', function ($ http) {var self = this; self.svg = {show: true, width: 400, height: 400};}]); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; (.)
I hope SVG is determined as the width and height of 400 as But they are not. When I use the browser development tool to inspect the SVG element, its size is 1054 x 931 (full screen in Chrome), 1520 x 281.6 ( Full screen in IE) or 300 x 150 (in) Why do I bind the width and height of SVG from AngleJes? Edit: It appears that I was wrong about If you do not know which features will be provided, issuing instructions is still an option. Here are examples to work with your style collection (directive codes are mostly mimicked and optimized in the corner): ng-attr-width = "MainCtrl.svg" ngistyle can be used to determine width and height, as comments suggest suggestions. To help write this, I am working to explain how it works (and why not your ng-attr-width ), and maybe ngStyle . ngStyle is itself a. It adds a $ watchCollection to the ng-style attribute and based on CSS rules Adds. No Instructions for ngAttrWidth , but if you want one, you can modify the element to modify $ for the relevant attribute Watch can make it much easier by adding it to be more relevant for SVG features which can not be taken from CSS (like path ). ng-atri-width , any Angular's argument is to modify properties for ng-attr -prefixed attributes. It works well if you always find that this instruction will be given the same quality.
Comments
Post a Comment