The problem is how to pass the value of the Viewbag in my angular js

On Tue, Aug 2, 2016 at 11:27 AM, Marina L <[email protected]> wrote:

> Its my MVC Controller. It written in C and I execute my queries there. So
> I need if my query is null then I turn the ViewBag to false. If has values
> I turn my ViewBag to true.
>
>
> On Tue, Aug 2, 2016 at 10:18 AM, hirdesh tomar <[email protected]>
> wrote:
>
>> If your controller is also written in angular js then why not use same
>> controller for that <div> page? In case there is a necessity to use a
>> separated controller then you may have to write an angular service to pass
>> values between controllers. There are other options as well like using
>> $localStorage angular service or by using rootScope variable.
>>
>> Thanks,
>> Hirdesh
>>
>> On Aug 2, 2016 12:03 PM, "Marina L" <[email protected]> wrote:
>>
>>> hi,
>>> thank you for your reply. How can I pass the ViewBag  (true or false)
>>> value from my mvc controller to angular controller?
>>>
>>> On Tue, Aug 2, 2016 at 6:13 AM, hirdesh tomar <[email protected]>
>>> wrote:
>>>
>>>> Hi Marina,
>>>>
>>>> Not sure about this approach but you can use "ng-show" directive in
>>>> angular js to hide or unhide a div.
>>>>
>>>> In your controller define a flag on scope like this
>>>>
>>>> $scope.viewBagFlag = { hideShow : true };
>>>>
>>>> and set $scope.viewBagFlag to false when your "viewBag" variable
>>>> becomes false.
>>>>
>>>> In your html use this flag to show or hide that div.
>>>>
>>>> <div ng-show="viewBagFlag.hideShow">
>>>> </div>
>>>>
>>>> Hope this helps!
>>>>
>>>> Thanks,
>>>> Hirdesh
>>>>
>>>> On Aug 1, 2016 2:11 PM, "Marina L" <[email protected]> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I use Angular js in my MVC app.
>>>>>
>>>>> I need to hide a div when my viewbag is false
>>>>>
>>>>> I have try this
>>>>>
>>>>>  public ActionResult Index()
>>>>>         {
>>>>>             ViewBag.total = false;
>>>>>             return View();
>>>>>         }
>>>>>
>>>>>
>>>>> My View
>>>>>
>>>>>
>>>>> @{
>>>>>             var total= (string) ViewBag.total;
>>>>>          }
>>>>>         <div ng-if="total">
>>>>> content here
>>>>>         </div>
>>>>>
>>>>>
>>>>> and also this from here
>>>>> http://stackoverflow.com/questions/27673786/angular-ng-if-not-working-with-razor-syntax
>>>>>
>>>>> but it doesn't work. Any idea?
>>>>>
>>>>> thank you
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "AngularJS" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/angular.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to