string a = ICH.GET_Status1();
这个函数返回字符串,我必须在我的 Angular js 代码中显示这个字符串
<body ng-controller="controllerng">
<p>{{varName}}</p>
<script>
var app = angular.module('appng', []);
app.controller('controllerng', function ($scope, $http) {
$scope.varName = a;//here i used string
});
</script>
最佳答案
您可以将该变量作为 javascript 全局变量放入您的 C# View 中。
例如,在 C# MVC 中,我们可以将其放在 index.cshtml 中
<html>
<body>
<script>
var a = '@viewBag.a';
</script>
</body>
</html>
然后在你的 Controller 中
.controller("MyController", function($scope){
$scope.a = a;
});
关于javascript - 我的 C# 函数返回一个 json 字符串。现在我必须在我的 Angular JS 代码中使用它。那么我必须使用哪个标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37067173/