角度不渲染< br>在我的json中 [英] Angular not rendering <br> in my json
问题描述
我正在尝试使用angular,它将在页面上显示json的元素.它不起作用.我想做的很简单.但它不起作用
I am trying to use angular which displays on the page the element from the json. Its not working. What I am trying to do is pretty straightforward. But its not working
这是我的代码:
http://jsfiddle.net/sqxmyrcj/1/
(function(){
var app = angular.module('store', []);
app.controller('PortfolioController',function(){
this.product = gem;
});
var gem =
{
name: 'TEmp',
aboutme: 'A Computer Science student at <br>The University Canada.<br> <br>A Software Engineer'
};
})();
推荐答案
有两种管理控制器的方法,您使用的是controller as
方法,而大多数钓鱼者使用的另一种方法是$scope
There are 2 ways of managing your controller, you were going for the controller as
approach and the other which is more widely used by most angularians is $scope
.
基本上$ scope注入到控制器中,并充当该容器的主要对象
Basically $scope is injected into the controller and acts a the main object for that container
app.controller('Ctrl', function ($scope) {
$scope.product = {
name: ...
};
});
...
{{product.name}}
controller as
方法具有更大的灵活性,但也具有更多的原型复杂性.
The controller as
method allows greater flexibility but also has more prototypical complexity.
app.controller('Controller', function () {
this.product = {
name: ...
};
});
<div ng-controller="Controller as ctrl">
{{ctrl.product.name}}
</div>
这篇关于角度不渲染< br>在我的json中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!