Angularjs doesnot print from function
Angularjs doesnot print from function
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="canerApp" ng-controller="canerCtrl">
<br> {{text}}f
</div>
<script type="text/javascript">
var app = angular.module('canerApp', []);
app.controller('canerCtrl', function($scope){
$scope.text ="ff";
});
</script>
</body>
</html>
this works and print
fff
你可以在这里看到
http://plnkr.co/edit/gP2NcC38JPsabQFacGkb?p =
预览但这不起作用
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myController">
<br> {{text}}f
<br> {{text}}fh
</div>
<script type="text/javascript">
var app= angular.module('myApp',[]);
app.controller('myController', function($scope){
$scope.text="afasfa";
});
</script>
</body>
</html>
可以在这里看到https://plnkr.co/edit/1I90i5ANdrA6OUmZry65?p=preview
除了控制器名和应用程序名之外,它们完全相同。
我花了一个小时还是没弄明白。而且也找不到在线错误查找器来验证是否一切都为真。实际上不同之处在于,在你的第一个代码中,你使用的是http
协议plnkr,在你的第二个代码中,你使用的是https
plnkr,并使用http
协议angular库。
所以只要在脚本标签中将协议更改为https
。
感谢@Ashu Jha提供的plink https://plnkr.co/edit/ivUsQBpop2864XP9s81s?p=preview
我通常使用code.angular.org作为我的angular cdn站点。如果你的http到https是错误的。你可以直接使用浏览器的控制台选项卡找到这些bug在这种情况下,错误是
"Mixed Content: The page at 'https://plnkr.co/edit/1I90i5ANdrA6OUmZry65?p=preview' was loaded over HTTPS, but requested an insecure script 'http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js'. This request has been blocked; the content must be served over HTTPS."
尝试使用https。
<!DOCTYPE html>
<html>
<script src="https://code.angularjs.org/1.3.0/angular.js"></script>
<body>
<div ng-app="myApp" ng-controller="myController">
<br> {{text}}f
</div>
<script type="text/javascript">
var app= angular.module('myApp',[]);
app.
controller('myController', function($scope){
$scope.text="afasfa";
});
</script>
</body>
</html>
相关文章:
- 直接在函数声明上使用function.prototype.bind
- jQuery:.click(function(){(element),collapse('show',f
- 如果连接类型为none,则Javascript Function Only警报
- onLoad function phonegap android
- Validate JSON from Mongo?
- Get JSON from an url
- creating objects from variables ES6
- reducers在redux中得到Function not Object,what'it’他错了
- getting id from jsp
- jquery使用name from变量按类选择元素
- WIll window.addEventListener(“加载”,function(),false);等待浏览器自动填
- Using jQuery with classes from ES6
- 如何计算与php中的CRC32函数兼容的arrayBuffer(javascript中的From FileReader)
- $(document).ready和jQuery(function($)不工作;jQuery已定义,但脚本尚未定义;t进
- Call a function from a <a> tag in javascript?
- Webpack DefinePlugin from async function
- Call python FUNCTION from javascript
- Angularjs doesnot print from function
- Calling VB.NET WebMethod Function from Javascript
- jQuery data() from a function